Php – Why is the php script not running on boot? Running from command line works fine

amazon-web-servicescronPHPubuntu-11.10

I have placed the following information into my crontab file by entering "crontab -e" (in both root and "ubuntu" users, on a 32 bit Canonical Ubuntu AWS instance):

@reboot /usr/bin/php /usr/share/nginx/www/cron/updateIp.php

I have also tried:

@reboot /usr/bin/php /usr/share/nginx/www/cron/updateIp.php >> /home/ubuntu/crontab.log

And /home/ubuntu/crontab.log contains nothing after two reboots.

I imagine that php and/or nginx is not loaded when this cronjob is attempting to run?

Without any error logs to check however, I am at a loss as to what to do next..?

EDIT: Even after logging into the box via SSH with the same user that the crontab -e was created under… the cronjob does not run.

EDIT 2: (results of syslog):

Nov  9 13:29:02 ip-10-122-254-128 CRON[603]: (root) CMD (php /usr/share/nginx/www/cron/updateIp.php)
Nov  9 13:29:02 ip-10-122-254-128 CRON[604]: (ubuntu) CMD (/usr/bin/php /usr/share/nginx/www/cron/updateIp.php >> /home/ubuntu/crontab.log 2>&1)

EDIT 3: This link actually provided the answer I was looking for. Apparently I needed to install php-cgi and mention it specifically, even though whereis php does not show it? Simply installing php5-cgi and changing /usr/bin/php to /usr/bin/php-cgi worked like a charm. I already had php5-cli and php5-fpm installed so I figured php5-cgi wasn't necessary, but I suppose it must have been.

Best Answer

Check stat cron is running

status cron 
cron start/running, process 1380

or

ps aux | grep cron
root      1380  0.0  0.0   2092   876 ?        Ss   Nov03   0:02 cron

If it's running or not then have a look in /var/log/syslog and see if there are any relevant messages.

grep CRON /var/log/syslog
Nov  9 11:18:29 iain-ubuntu cron[3509]: (CRON) STARTUP (fork ok)
Nov  9 11:18:29 iain-ubuntu cron[3509]: (CRON) INFO (Skipping @reboot jobs -- not system startup)