# Cron not working - working only from ssh

**URL:** <https://forum.mautic.org/t/cron-not-working-working-only-from-ssh/32624>\
**Category:** Mautic 4 Install/Upgrade Support\
**Created:** [July 2, 2024, 4:05pm UTC](https://forum.mautic.org/t/cron-not-working-working-only-from-ssh/32624 "2024-07-02T16:05:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stfnet](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stfnet/32/2021_2.png) [@stfnet](https://forum.mautic.org/u/stfnet)\
**Post date:** [July 2, 2024, 4:05pm UTC](https://forum.mautic.org/t/cron-not-working-working-only-from-ssh/32624/1 "2024-07-02T16:05:18Z")

</div>

_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 👆

_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 🙏

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [July 3, 2024, 7:37am UTC](https://forum.mautic.org/t/cron-not-working-working-only-from-ssh/32624/2 "2024-07-03T07:37:52Z")

</div>

Hi, who is running this crontab? Root?

---

<div class="post-metadata">

**Author:** ![stfnet](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stfnet/32/2021_2.png) [@stfnet](https://forum.mautic.org/u/stfnet)\
**Post date:** [July 3, 2024, 11:28am UTC](https://forum.mautic.org/t/cron-not-working-working-only-from-ssh/32624/3 "2024-07-03T11:28:44Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [July 4, 2024, 3:03pm UTC](https://forum.mautic.org/t/cron-not-working-working-only-from-ssh/32624/4 "2024-07-04T15:03:38Z")

</div>

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