I\'ve spent two days trying to understand why I can not get cron to work on my Ubuntu EC2 instance. I\'ve read the documentation. Can anyone help? All I want is to get a wor
In my case the cron job was working but the script failed it was running failed. The failure reason was due to the fact that I used relative path instead of absolute path in my include line inside the script.
Don't forget to specify the user to run it as. Try creating a new file inside your /etc/cron.d
folder named after what you want to do like getnytimes
and have the contents of that file just be:
02 * * * * root /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/
Your cron daemon is not running. When you're running ps aux | grep crond
the result is showing that only the grep command is running. Be aware of this whenever you run ps aux | grep blah
.
Check the status of the cron service by running this command.
Try:
sudo service crond status
Additional information here: http://www.cyberciti.biz/faq/howto-linux-unix-start-restart-cron/.
Cron can be run in Amazon-based linux server just like in any other linux server.
crontab -e
on the command line.* * * * * /usr/bin/uptime > /tmp/uptime
cat /tmp/uptime
).uptime
command on the command line.The scenario above worked successfully on a server with the Amazon Linux O/S installed, but it should work on other linux boxes as well. This modifies the crontab of the current user, without touching the system's crontabs and doesn't require the user inside the crontab entry, since you are running things under your own user. Easier, and safer!
running
/usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/
gives me an error
/home/ubuntu/backups/testfile: No such file or directory
is this your issue? I guess cron is not writing this error to anywhere you can redirect stderr to stdout and see the error like this :
02 * * * * /usr/bin/wget -O /home/ubuntu/backups/testfile http://www.nytimes.com/ > /home/ubuntu/error.log 2&>1
One of the possible reasons for cronjob not running: Ensure that the server time and your cronjob time are same. I wasted a lot of time because of this.