Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Issue with cron
PostPosted: Mon Aug 18, 2008 9:46 pm 
Offline
Newbie

Joined: Mon Aug 18, 2008 9:44 pm
Posts: 4
I'm using CentOS 5 and I need to get cron working and I'm not sure what the problem is. As a test I've done the following:

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.


Top
   
 Post subject:
PostPosted: Mon Aug 18, 2008 9:54 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
Any information in /var/log/cron ?

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Mon Aug 18, 2008 10:16 pm 
Offline
Newbie

Joined: Mon Aug 18, 2008 9:44 pm
Posts: 4
These are the lines that are repeated over and over in /var/log/cron:

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')


Top
   
 Post subject:
PostPosted: Mon Aug 18, 2008 10:21 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
Then cron is trying to run the command. Did you upload the file from a Windows PC? Is it in DOS mode? Try running dos2unix on /root/date.sh just in case

_________________
Rgds

Stephen

(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Mon Aug 18, 2008 10:29 pm 
Offline
Newbie

Joined: Mon Aug 18, 2008 9:44 pm
Posts: 4
Sorry the single quotes are not suppose to be there. It should be:

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.


Top
   
 Post subject:
PostPosted: Mon Aug 18, 2008 10:41 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
Well, cron is definitely trying to run the job. So
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)

_________________
Rgds

Stephen

(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Mon Aug 18, 2008 11:37 pm 
Offline
Newbie

Joined: Mon Aug 18, 2008 9:44 pm
Posts: 4
Did all of those. Still not working :(


Top
   
 Post subject:
PostPosted: Wed Aug 20, 2008 1:58 pm 
Offline
Senior Member

Joined: Sun Nov 30, 2003 2:28 pm
Posts: 245
Works for me:
Code:
/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 '* * * * *').

_________________
The irony is that Bill Gates claims to be making a stable operating system and Linus Torvalds claims to be trying to take over the world.
-- seen on the net


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group