I have a Amazon EC2 Linux micro instance server that I need to fire an hourly process on. I have chosen to use crontab and cannot get it to fire.
I placed a *.sh file in the /etc/cron.hourly
$ sh /etc/cron.hourly/notify.sh
the script behaves as expected.crontab
contents are at the endnotify.php logs when it is called so I can tell that the service is never running. Any ideas?
Thanks
curl localhost/notify.php
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
I added this line to /etc/crontab
* * * * * root curl /etc/notify.sh >>/var/log/cron.log
This created output ever minute that helped me track down the issue. In the end I had a typo in the script.
Thanks for everyone's help!!
Sounds like the environment might differ; try something like /bin/echo hello world (use which to find their echo). If that works, it's probably a $PATH problem.
I'd recommend to check the file permissions. x-bit should be set. Another thing is #!/bin/sh in the first line of your script. Last one probably isn't necessary.