Issue with cron
1) In /etc/cron.d I've created a file called date with the following contents
2) */1 * * * * root date >> /root/thedate
3) This works perfectly. It sends the date every minute to /root/thedate with no problem
Then when I tried the following, it would not work:
1) In /etc/cron.d I changed the file named "date" to contain the following:
2) */1 * * * * root /root/date.sh
3) The contents of /root/date.sh is the following:
!/bin/sh
date >> /root/thedate
4) I chmoded /root/date.sh to 700 and was able to run it by executing ./date.sh
5) However, crond would not run this cron job and I am confused
Any help is appreciated.
7 Replies
Aug 18 22:11:01 myhost crond[14990]: (root) CMD ('/root/date.sh')
Aug 18 22:12:01 myhost crond[14993]: (root) CMD ('/root/date.sh')
Aug 18 22:13:01 myhost crond[15000]: (root) CMD ('/root/date.sh')
Aug 18 22:11:01 myhost crond[14990]: (root) CMD (/root/date.sh)
Aug 18 22:12:01 myhost crond[14993]: (root) CMD (/root/date.sh)
Aug 18 22:13:01 myhost crond[15000]: (root) CMD (/root/date.sh)
I wrote the cron job in nano through SSH.
1) make sure it's in unix format (dos2unix)
2) fully qualify every path (/bin/date and not just date)
3) Check to see if anything is appearing in root mail (cron failures are typically emailed)
/etc/cron.d$ cat date
* * * * * root /root/date.sh
/etc/cron.d$ ls -l /root/*date*
-rwx------ 1 root root 32 Aug 20 12:52 /root/date.sh*
-rw-r--r-- 1 root root 87 Aug 20 12:56 /root/thedate
/etc/cron.d$ sudo cat /root/date.sh
#!/bin/sh
date >> /root/thedate
/etc/cron.d$ cat /root/thedate
Wed Aug 20 12:52:35 CDT 2008
Wed Aug 20 12:55:01 CDT 2008
Wed Aug 20 12:56:01 CDT 2008
All on my linode running Debian etch. The first line in "thedate" is from a manual run; the next two are from cron updates. (BTW, '*/1 * * * ' is the same as ' * * * *').