Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have noticed on my RHEL 5.5 that cron daily starts an hour later (at 1AM instead of midnight). System and hardware clock are the same. How can i set it so it will start at midnight?

date

[root@a ~]# date
Wed Mar  9 12:44:35 EST 2011

hwclock

[root@a ~]# /sbin/hwclock -r
Wed 09 Mar 2011 12:44:42 PM EST  -0.000484 seconds

crontab

0 0 * * *    /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1

cron log

Mar  7 01:00:01 host crond[30420]: (root) CMD (/usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1)

clock

[root@a ~]# cat /etc/sysconfig/clock
ZONE="America/New York"
UTC=true
ARC=false
share|improve this question
2  
You should run the ntpd daemon instead of using ntpdate. –  Dennis Williamson Mar 9 '11 at 19:03
    
What are the contents of /etc/sysconfig/clock ? –  sciurus Mar 9 '11 at 19:54
    
I have edited the question with the additional info –  Paxxil Mar 9 '11 at 20:56

4 Answers 4

up vote 2 down vote accepted

Have you changed the system timezone setting? If so, did you restart the crond service afterwards?

Regardless, I would restart the cron deamon, to make sure it's using the correct timezone.

# /sbin/service crond restart
share|improve this answer
    
Nothing has been changed after last server restart. So the given info was the same before. And I've also tried that. –  Paxxil Mar 9 '11 at 21:21
1  
hum... apparently there have been some changes made by my coworker. After server restart it seems to work now. Only crond restart was not enough. –  Paxxil Mar 9 '11 at 21:40

IHMO, there's nothing wrong with daily cron jobs running at 1:00 am, as long as they run daily.

Check your /etc/crontab file, mine (RHEL 5.4) runs at 2:00 am by default:

# 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

Look for your the cron.daily line. Edit to suit, e.g.:

01 0 * * * root run-parts /etc/cron.daily
share|improve this answer
    
It is for custom cron jobs. 0 0 * * * /scrip.php executes at 1 AM instead of Midnight. –  Paxxil Mar 9 '11 at 21:34

If you are talking about things running out of /etc/cron.daily, those are defined in /etc/crontab. Make sure the entry for /etc/cron.daily is set to run at midnight, by default it runs at 04:02.

share|improve this answer
    
Default on some systems, maybe. Others may be different. –  Dennis Williamson Mar 9 '11 at 23:05

It is not always "enough" to restart crond.

  1. set /etc/localtime as symlink to link with one of /usr/share/zoneinfo/... time zone file
  2. set /etc/sysconfig/clock to ZONE="CONTINENT/TOWN" (+ UTC=true and ARC=false)
  3. restart the whole machine
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.