Issues executing PHP from cron

I had issues executing php from cron. Here’s my initial cron request

00 09 * * * php /home/automation/script.php

I read some suggestions about using /usr/bin/php /home/automation/script.php but that didn’t help either. Also appended the output of the cron job to a log file in which case, the file would get created but there wouldn’t be any output. Finally, after some hit and trial, I created a bash script to execute the php and executed the bash script from cron. Another catch with the bash script was that I had to “cd” to the directory where my php script existed, even providing the full path of the php didn’t work. So here’s my bash script to execute cron

cd /home/automation/
php script.php

and the cron looks like
00 09 * * * /home/automation/

** Also make sure that the bash script file has execute permissions (chmod 755


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s