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
and the cron looks like
00 09 * * * /home/automation/execute-script.sh
** Also make sure that the bash script file has execute permissions (chmod 755 execute-script.sh).