Mautic CronJobs

Your software
My Mautic version is: v5.1.1
My PHP version is: 8.1.29
My Database type and version is: pdo_mysql, 5.7.44

Your problem
My problem is:
I am trying to install cronjobs to run the required mautic php commands automatically. Using crontab -e, I placed these 3 lines at the bottom of the file:

          • php /var/www/html/bin/console mautic:segments:update
          • php /var/www/html/bin/console mautic:campaigns:update
          • php /var/www/html/bin/console mautic:campaigns:trigger

Using the command ‘service cron status’ I see that it is running. However the commands still aren’t executed unless I manually type them into the command line (these command work properly when typed in the command line)

These errors are showing in the log:
There are no errors in the log

Steps I have tried to fix the problem:
I have tried restructuring the php commands themselves and setting them on different timing but non working. I do properly get the required cronjobs running from terminal, NOT using channel. I am access the Mautic application by running docker exec -it on the container hosting Mautic.

Most likely your $PATH is missing/wrong.

Try this:
$ which php

Then, use the output instead of just “php”

i.e.
if the “which php” cmd returned “/usr/local/bin/php”

current crontab:

* * * * * php /var/www/html/bin/console mautic:segments:update
* * * * * php /var/www/html/bin/console mautic:campaigns:update
* * * * * php /var/www/html/bin/console mautic:campaigns:trigger

New crontab:

* * * * * /usr/local/bin/php /var/www/html/bin/console mautic:segments:update
* * * * * /usr/local/bin/php /var/www/html/bin/console mautic:campaigns:update
* * * * * /usr/local/bin/php /var/www/html/bin/console mautic:campaigns:trigger