Cronjobs does not execute php scripts, email alerts are not accepted!

Here is my situation:

I am trying to run a php script via cron and I have crontab (/ etc / crontab) which looks like this:

SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/var/www: MAILTO=<myemailaddress> mh dom mon dow user command * * * * * root /usr/bin/php /var/www/testing.php 

And when I run the command /usr/bin/php /var/www/testing.php from bash / sh, everything is dandy. This is just a basic PHP script that writes some gibberish to a file. However, my cronjob is not running. I used sudo service cron several times, but all to no avail. Did I miss something obvious here?

Thank you and welcome!

Decision

My own mistake! The executable php script that I ran wrote to a file that was not processed correctly - for example, the full path to the file was missing. Thanks for helping everyone!

+4
source share
1 answer

Create a shell script and put the PHP command there. Make it executeabl and put it in crontab.

Then you can better track and modify the command, as well as easier to set up the environment (vars, paths) for the php script.

0
source

All Articles