LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron.hourly Not Working (https://www.linuxquestions.org/questions/linux-newbie-8/cron-hourly-not-working-747321/)

lapidarynewbie 08-13-2009 12:19 PM

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

unSpawn 08-13-2009 12:33 PM

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/.

lapidarynewbie 08-13-2009 12:52 PM

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.

unSpawn 08-14-2009 06:29 AM

Quote:

Originally Posted by lapidarynewbie (Post 3642141)
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 (Post 3642141)
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 (Post 3642141)
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 (Post 3642141)
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?

lapidarynewbie 08-14-2009 08:01 AM

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


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