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.

  • What AMI id are you running? In what EC2 region? – Eric Hammond Nov 8 '11 at 3:16
  • 1
    Try this >> /home/ubuntu/crontab.log 2>&1. – quanta Nov 8 '11 at 3:18
  • 1
    As with any cron problem, the first place you should look at is the environment, quickly followed by permissions. – Zoredache Nov 8 '11 at 8:35
  • @EricHammond I am running ami-a7f539ce (32 bit oneric) in us-east-1. – darkAsPitch Nov 8 '11 at 16:18
  • 2
    In addition to sending stdout to the log file, also send stderr so you get error messages: ...updateIp.php >> /home/ubuntu/crontab.log 2>&1 – Eric Hammond Nov 8 '11 at 21:33

Check stat cron is running

status cron 
cron start/running, process 1380


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)
  • I have checked to see that cron is running, and was elated to see my commands listed in the syslog file (right around the time they should be), but there wasn't much other information explaining why exactly the ip_address.txt file did not update itself. It simply claims the php script was run, and shows me the commands, but ip_address.txt is unchanged. – darkAsPitch Nov 9 '11 at 19:08
  • @darkAsPitch: If ip_address.txt is unchanged, this probably means that cron is working fine, but that your updateIp.php isn't working as expected. To test this, replace updateIp.php which something which simply prints to standard out. You should see the output in /home/ubuntu/crontab.log. Remember that cron runs with a minimal environment which is different then your typical commandline environment. – Stefan Lasiewski Nov 9 '11 at 19:26
  • for some reason I had to specify /usr/bin/php-cgi from the crontab file, when /usr/bin/php works normally. It not works. Thank you for all your help. – darkAsPitch Nov 28 '11 at 4:09

Most probably, the cron service is turned off

  • cron was indeed running, but I had to specify php-cgi instead of php in the crontab area for some reason. Do you know why? – darkAsPitch Nov 9 '11 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.