Command "mautic:campaigns:update " is not defined

Your software
My Mautic version is: 5.1.0
My PHP version is: 8.1.27
My Database type and version is: MariaDB 10.6.18

Your problem
My problem is:
The CRON jobs are firing and causes errors in the server log every time they fire. The errors are the same for the mautic.campaigns.trigger, mastic.campaigns.update and mastic.segments.update cron jobs.

These errors are showing in the log:
mautic.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "mautic:campaigns:update " is not defined. Did you mean one of these? doctrine:schema:update mautic:campaign:delete-event-logs mautic:campaigns:execute mautic:campaigns:messagequeue mautic:campaigns:messages mautic:campaigns:rebuild mautic:campaigns:summarize mautic:campaigns:trigger mautic:campaigns:update mautic:campaigns:validate mautic:plugins:update mautic:segments:update (uncaught exception) at /var/www/html/vendor/symfony/console/Application.php line 720 while running console command UNKNOWN [stack trace] #0 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(116): Symfony\Component\Console\Application->find() #1 /var/www/html/vendor/symfony/console/Application.php(259): Symfony\Bundle\FrameworkBundle\Console\Application->find() #2 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun() #3 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #4 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run() #5 {main} {“hostname”:“ip-XXXXXXXXXX”,“pid”:187413}

Steps I have tried to fix the problem:
Manually run the CRON job commands at CLI and they process okay (although zero actual updates or changes made - not a busy site) with no errors at runtime.
Googled for answers to these log errors.

This looks like a bad/wrong $PATH

Try this:
$ which php

The, in your cron, use that output (i.e. /usr/local/bin/php) and replace
* * * * * php /path/to/your/console <your cmd>
with
* * * * * /usr/local/bin/php /path/to/your/console <your cmd>

Much appreciated @marcus42 - I implemented your suggestion, rebooted the server and checked the error log. Unfortunately, it seems to still be happening - here are the recent log entries detailing the error:

[2024-12-08T10:50:01.758796+00:00] mautic.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "mautic:campaigns:update " is not defined. Did you mean one of these? doctrine:schema:update mautic:campaign:delete-event-logs mautic:campaigns:execute mautic:campaigns:messagequeue mautic:campaigns:messages mautic:campaigns:rebuild mautic:campaigns:summarize mautic:campaigns:trigger mautic:campaigns:update mautic:campaigns:validate mautic:plugins:update mautic:segments:update (uncaught exception) at /var/www/html/vendor/symfony/console/Application.php line 720 while running console command UNKNOWN [stack trace] #0 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(116): Symfony\Component\Console\Application->find() #1 /var/www/html/vendor/symfony/console/Application.php(259): Symfony\Bundle\FrameworkBundle\Console\Application->find() #2 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun() #3 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #4 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run() #5 {main} {“hostname”:“ip-XXX-XX-XX-XX”,“pid”:1088}
[2024-12-08T10:55:02.186774+00:00] mautic.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "mautic:campaigns:trigger " is not defined. Did you mean one of these? mautic:campaign:delete-event-logs mautic:campaigns:execute mautic:campaigns:messagequeue mautic:campaigns:messages mautic:campaigns:rebuild mautic:campaigns:summarize mautic:campaigns:trigger mautic:campaigns:update mautic:campaigns:validate (uncaught exception) at /var/www/html/vendor/symfony/console/Application.php line 720 while running console command UNKNOWN [stack trace] #0 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(116): Symfony\Component\Console\Application->find() #1 /var/www/html/vendor/symfony/console/Application.php(259): Symfony\Bundle\FrameworkBundle\Console\Application->find() #2 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun() #3 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #4 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run() #5 {main} {“hostname”:“ip-XXX-XX-XX-XX”,“pid”:1098}
[2024-12-08T11:00:01.612913+00:00] mautic.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "mautic:segments:update " is not defined. Did you mean one of these? doctrine:schema:update mautic:campaigns:update mautic:plugins:update mautic:segments:rebuild mautic:segments:update (uncaught exception) at /var/www/html/vendor/symfony/console/Application.php line 720 while running console command UNKNOWN [stack trace] #0 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(116): Symfony\Component\Console\Application->find() #1 /var/www/html/vendor/symfony/console/Application.php(259): Symfony\Bundle\FrameworkBundle\Console\Application->find() #2 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun() #3 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #4 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run() #5 {main} {“hostname”:“ip-XXX-XX-XX-XX”,“pid”:1109}
[2024-12-08T11:05:02.040405+00:00] mautic.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "mautic:campaigns:update " is not defined. Did you mean one of these? doctrine:schema:update mautic:campaign:delete-event-logs mautic:campaigns:execute mautic:campaigns:messagequeue mautic:campaigns:messages mautic:campaigns:rebuild mautic:campaigns:summarize mautic:campaigns:trigger mautic:campaigns:update mautic:campaigns:validate mautic:plugins:update mautic:segments:update (uncaught exception) at /var/www/html/vendor/symfony/console/Application.php line 720 while running console command UNKNOWN [stack trace] #0 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(116): Symfony\Component\Console\Application->find() #1 /var/www/html/vendor/symfony/console/Application.php(259): Symfony\Bundle\FrameworkBundle\Console\Application->find() #2 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun() #3 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #4 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run() #5 {main} {“hostname”:“ip-XXX-XX-XX-XX”,“pid”:1119}
[2024-12-08T11:10:01.470374+00:00] mautic.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "mautic:campaigns:trigger " is not defined. Did you mean one of these? mautic:campaign:delete-event-logs mautic:campaigns:execute mautic:campaigns:messagequeue mautic:campaigns:messages mautic:campaigns:rebuild mautic:campaigns:summarize mautic:campaigns:trigger mautic:campaigns:update mautic:campaigns:validate (uncaught exception) at /var/www/html/vendor/symfony/console/Application.php line 720 while running console command UNKNOWN [stack trace] #0 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(116): Symfony\Component\Console\Application->find() #1 /var/www/html/vendor/symfony/console/Application.php(259): Symfony\Bundle\FrameworkBundle\Console\Application->find() #2 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun() #3 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #4 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run() #5 {main} {“hostname”:“ip-XXX-XX-XX-XX”,“pid”:1185}
[2024-12-08T11:15:01.902048+00:00] mautic.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "mautic:segments:update " is not defined. Did you mean one of these? doctrine:schema:update mautic:campaigns:update mautic:plugins:update mautic:segments:rebuild mautic:segments:update (uncaught exception) at /var/www/html/vendor/symfony/console/Application.php line 720 while running console command UNKNOWN [stack trace] #0 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(116): Symfony\Component\Console\Application->find() #1 /var/www/html/vendor/symfony/console/Application.php(259): Symfony\Bundle\FrameworkBundle\Console\Application->find() #2 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun() #3 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #4 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run() #5 {main} {“hostname”:“ip-XXX-XX-XX-XX”,“pid”:1196}
[2024-12-08T11:20:02.338071+00:00] mautic.ERROR: Symfony\Component\Console\Exception\CommandNotFoundException: Command "mautic:campaigns:update " is not defined. Did you mean one of these? doctrine:schema:update mautic:campaign:delete-event-logs mautic:campaigns:execute mautic:campaigns:messagequeue mautic:campaigns:messages mautic:campaigns:rebuild mautic:campaigns:summarize mautic:campaigns:trigger mautic:campaigns:update mautic:campaigns:validate mautic:plugins:update mautic:segments:update (uncaught exception) at /var/www/html/vendor/symfony/console/Application.php line 720 while running console command UNKNOWN [stack trace] #0 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(116): Symfony\Component\Console\Application->find() #1 /var/www/html/vendor/symfony/console/Application.php(259): Symfony\Bundle\FrameworkBundle\Console\Application->find() #2 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(82): Symfony\Component\Console\Application->doRun() #3 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun() #4 /var/www/html/bin/console(16): Symfony\Component\Console\Application->run() #5 {main} {“hostname”:“ip-XXX-XX-XX-XX”,“pid”:1209}

Save yourself few minutes. No need to reboot.

With Linux, you only have to reboot following a kernel update or a hardware change. Otherwise we only restart/reload services, not the physical/cloud server, when needed.

i.e. The cronjob service must be reloaded after a crontab change (this is done automatically - no need to do anything upon saving the tab)

The first thing that I would try is to run the cmd directly from the CLI (what you’ve already done).

If it does work (you’ve reported that yes it does), I would think about a session problem where the bin is nowhere to be found.

Or, second option, the cron that see the blank/space between the cmd and the argument as a new line/new cmd.

The solution to the first problem (session) is to either re-declare the $PATH variable or fully declare the bin path (in this case, the php bin path). Like that:
* * * * * /path/to/php /path/to/script

The solution to the second problem would be to quote your cmd like so:
* * * * * php "/path/to/script argument --argument=variable"

Both solutions combined:
* * * * * /path/to/php "/path/to/script argument --argument=variable"

And while reading your initial post again, the second option (the blank) seems to be the current best bet.

**And of course, you aren’t root. Right? Because a webmaster is never root. And always a regular permission-less user (i.e. can’t do server reboot/reload/restart). Otherwise you’ll :100: break your web app, regardless of the framework.

Thanks @marcus42, I spotted what looks like an extra ‘space’ at then of the line too but in crontab -e I tried to check and delete any erroneous space but didn’t seem to be one.

I’m not sure I understand the:

The solution to the second problem would be to quote your cmd like so:
* * * * * php "/path/to/script argument --argument=variable"

If my crontab lines read like the below - what change do I need to make to them?

0,15,30,45 * * * * /usr/bin/php /var/www/html/bin/console mautic:segments:update
5,20,35,50 * * * * /usr/bin/php /var/www/html/bin/console mautic:campaigns:update
10,25,40,55 * * * * /usr/bin/php /var/www/html/bin/console mautic:campaigns:trigger

That would be
0,15,30,45 * * * * /usr/bin/php "/var/www/html/bin/console mautic:segments:update"

@marcus42 thank you so much, I really appreciate you taking the time to share your knowledge nad help with my problem. This looks like it’s fixed it with no more entries appearing in the log.

Thanks again. :+1:

1 Like

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.