views:

55

answers:

3

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

  • If I run $ sh /etc/cron.hourly/notify.sh the script behaves as expected.
  • I have checked to see if the cron service is running and it is.
  • I have checked crontab contents are at the end

notify.php logs when it is called so I can tell that the service is never running. Any ideas?

Thanks

contents of: /etc/cron.hourly/notify.sh

curl localhost/notify.php

contents of: /etc/crontab

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 
+1  A: 

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.

Michael Kjörling
+1  A: 

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.

Max Doronin
A: 

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!!

Jamey McElveen