LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-13-2009, 01:19 PM   #1
lapidarynewbie
LQ Newbie
 
Registered: Jun 2009
Posts: 17

Rep: Reputation: 0
cron.hourly Not Working


Linux OS: CentOS 5.3

Was having some problems with the "root : command not found" message from an hourly system cron job (ntpdate). Per another post on the subject, I backed-up (copied) the old system crontab, used crontab -r to remove it, and checked the "new" crontab. It actually did not differ from the old system crontab. Just for good measure I restarted crond.

Now the cron.hourly job doesn't seem to run at all. At first a /etc/crontab gave "Access Denied" with -rw-r--r--1 root root permissions. I changed it with chmod 755 and was able to do an /etc/crontab. I also confirmed the cron.hourly didn't run by doing an ls -lut cron.hourly which showed the last execution to be before more than an hour ealier. (The permissions on the cron.hourls / ntpdate job ar -rwxr-xr-x 1 root root.)

So, what happened? How can I fix this (even if I get that blinking message back again because at least the job was running)?

Many thanks in advance for your help to this cron newbie.

RichLich

Last edited by lapidarynewbie; 08-13-2009 at 01:27 PM. Reason: Added needed information
 
Old 08-13-2009, 01:33 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
W/o details "root : command not found" probably is just a PATH error. Saying "doesn't seem to run at all" doesn't mean a thing. Verify crond is running, then check /var/log/cron for details, eedit /etc/crontab to have it run in say 5 minutes then check again. List the directories and cronjobs access permissions. Verify with the installed package against the RPM database. BTW you never responded to http://www.linuxquestions.org/questi...essage-746474/.
 
Old 08-13-2009, 01:52 PM   #3
lapidarynewbie
LQ Newbie
 
Registered: Jun 2009
Posts: 17

Original Poster
Rep: Reputation: 0
1. Yes, crond is running. A service chrond restart stopped and started crond successfully.

2. Well, at 12:01 the cron.hourly seems to have run.

3. Oops! at 12:06 we get "crond[21928]: (*system*) BAD FILE MODE (/etc/crontab).

So, we're back to that again.

Permissions

an ls -l for /etc/crontab -rew-r--r-- 1 root root where as /etc/crontab -l gives permission denied

/etc/cron.hourly shows -rwxr-xr-x 1 root root for ntpdate

/etc/cron.daily shows -rwxr-xr-x for all jobs except 0logwatch (which points to /usr/shr/logwatch/scripts/logwatch.pl) which is lrwxrwxrwx 1 root root.

/etc/cron.weekly shows -rwxr-xr-x root root

/etc/cron.monthly shows -rwxr-xr-x root root

/etc/cron.mysqldump shows -rwxr-xr-x root root

And I don't know what I did to correct the "BAD FILE MODE" mainly because it was being hashed over by another guy here who knows a bit more about Linux than I do (but is often not available).

Of course, a lot of this is happening because the cron jobs were all ported over from an old RHEL 5.x installation.
 
Old 08-14-2009, 07:29 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by lapidarynewbie View Post
Oops! at 12:06 we get "crond[21928]: (*system*) BAD FILE MODE (/etc/crontab).
Not sure why it would help but change mode to 0400 and see if that still triggers a warning?


Quote:
Originally Posted by lapidarynewbie View Post
an ls -l for /etc/crontab -rew-r--r-- 1 root root where as /etc/crontab -l gives permission denied
What does "/etc/crontab -l" mean? Please just list lines (as in 'ls -l' or 'ls -Zl' if you run SELinux) and just don't show the ones you don't want to show.


Quote:
Originally Posted by lapidarynewbie View Post
And I don't know what I did to correct the "BAD FILE MODE" mainly because it was being hashed over by another guy here who knows a bit more about Linux than I do (but is often not available).
Then ask him. He does have email, doesn't he?


Quote:
Originally Posted by lapidarynewbie View Post
Of course, a lot of this is happening because the cron jobs were all ported over from an old RHEL 5.x installation.
How? Just copied over? Does one or do both use SELinux? If they do was the context copied over or set right for the destination? Can you post contents of /etc/crontab? Verify with the installed package against the RPM database?
 
Old 08-14-2009, 09:01 AM   #5
lapidarynewbie
LQ Newbie
 
Registered: Jun 2009
Posts: 17

Original Poster
Rep: Reputation: 0
All were copied over; except Winscp was used to first copy to my desktop and then from there to the new system. It appears, in doing this, the permissions did not get set correctly. Now that the permissions are set correctly, all is working just fine. (Apparently crontab doesn't like certain write permissions. Doing chmod 644 seemed to correct that. Well, at least no more error messages and checking the cron log shows successful execution.)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 09:09 AM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 07:37 PM
Cant seem to place items into cron.hourly mark8569 Linux - Software 5 12-09-2006 02:41 PM
script in cron.hourly not running hourly unholy Linux - Software 2 09-19-2006 09:21 PM
cron.hourly question Raw Kuts Linux - Newbie 1 08-18-2003 01:34 PM


All times are GMT -5. The time now is 02:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration