I have a cron job running a PHP script every five minutes; the PHP script executes two bash commands at the end of the script. I know the script is running due to a log file it appends to. When I run the PHP script manually via the Ubuntu Gnome Terminal both bash commands execute flawlessly; however when the PHP script is triggered via cron, the two bash commands are not ran. Any ideas?
$command = 'notify-send "' . count($infoleakPosts) . ' New Posts."';
`$command`;
$command = 'firefox http://example.com';
`$command`;
*/1 * * * * php /home/andrew/grab.php USERNAME PASSWORD # JOB_ID_1
Generally your cron scripts are going to be run under a different user account, and probably have a different environment path set up.
Try setting your command lines to use the full path to the command, ie. /path/to/notify-send "x New Posts"
.
You can use which notify-send
from your regular terminal to get the path to put into your script.
You can also grab the output from your command to help debugging. Use of the backtick operator will return the output, so you can assign it to a variable and/or dump it.
$output = `$command`;
error_log($output);