Cron not working - working only from ssh

Mautic: 4.4.12 (Apache2)
My PHP version is : PHP 8.0.30 (cli) (built: Jun 6 2024 16:51:07) ( NTS )
My MySQL/MariaDB version is mysql Ver 15.1 Distrib 10.6.18-MariaDB

/bin/php -v
PHP 8.0.30 (cli) (built: Jun 6 2024 16:51:07) ( NTS )
I guess it’s cli version :point_up_2:

My problem is :
I can’t get cron working using crontab -e here the code:

          • /bin/php /var/www/html/bin/console mautic:segments:update --env=prod
            */2 * * * * /bin/php /var/www/html/bin/console mautic:campaigns:update --env=prod
            */5 * * * * /bin/php /var/www/html/bin/console mautic:campaigns:trigger --env=prod

If I do from ssh terminal, it works perfectly:
/bin/php /var/www/html/bin/console mautic:segments:update

Steps:

  1. I made a segment with filter saying Tags including mycontact
  2. I create a new contact and add a tag: mycontact
  3. I wait for cron run and expect to see in the segment.
  4. If I lunch the script from ssh it works and I see the new contact in the segment.

isn’t it ?

Steps I have tried to fix the problem :
I have tried many solutions without success; before adding --env=prod at the end of the command I was having error in the log saying the command not recognized…etc now I don’t have any line in mautic logs.

Thanks :pray:

Hi, who is running this crontab? Root?

Hi Joey,
yes it’s running from root. could it be a problem ? If yes, I can try to change.

In the mean time, because it was a fresh installation I set-up a new env with Rocky Linux 9.4 / Nginx / PHP 8.0.30 / MariaDB and the same cron instructions are working like a charm. (this time I set cron under web server user)

from a working point of view I am moving forward with the new Env.

thank you

PS
You did great work with videos/tutorial. Very helpful resource! Thank you!

Thx, let me know if it doesn’t work.