Cronjobs getting the best of me ... Command line works, same command in Crontab does not!

Hi …

I’ve installed Mautic (email program). It needs 3 cronjobs to run properly.

  1. php /var/www/mydomainname/htdocs/app/console mautic:segments:update
  2. php /var/www/mydomainname/htdocs/app/console mautic:campaigns:update
  3. php /var/www/mydomainname/htdocs/app/console mautic:campaigns:trigger

I am on ubuntu 18.04 and am using PHP 7.0x.

When I do : sudo php /var/www/mydomainname/htdocs/app/console mautic:campaigns:trigger - or any other of the 3 listed above, they work without problem. I get the correct output and it’s executed.

However, when I put the same commands in a crontab, nothing happens.

I’ve tried everything. In the root crontab, in the www-data crontab, in my user crontab, with absolute paths to the PHP7.0 command (in /usr/bin/php7.0). Even tried first chaning to the php directory and what not.

For example :

        • /usr/bin/php7.0 /var/www/mydomainname/htdocs/app/console mautic:segments:update


        • sudo /usr/bin/php7.0 /var/www/mydomainname/htdocs/app/console mautic:segments:update


        • cd /usr/bin sudo php7.0 /var/www/mydomainname/htdocs/app/console mautic:segments:update

Nothing does the trick when using crontab.

Anyone know why?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


This is quite interesting. One thing that I’m noticing from your description is that when running the command manually you use sudo, would you mind confirming if the cronjobs that you are setting are under the root user or your low privileged user? My guess would be that your low privileged user does not have privileges to access the files in the /var/www/mydomainname/ directory.

Also, another suggestion here would be to add the following to your cronjobs: >>/path/to/somefile.log 2>&1 that way in the logs you would see some more information regarding what might be wrong with the jobs.

Hope that this helps! Regards, Bobby