1

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
3
  • 2
    You should run the ntpd daemon instead of using ntpdate. Mar 9, 2011 at 19:03
  • What are the contents of /etc/sysconfig/clock ?
    – sciurus
    Mar 9, 2011 at 19:54
  • I have edited the question with the additional info
    – Paxxil
    Mar 9, 2011 at 20:56

4 Answers 4

2

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
2
  • 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, 2011 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, 2011 at 21:40
1

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
0

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
1
  • It is for custom cron jobs. 0 0 * * * /scrip.php executes at 1 AM instead of Midnight.
    – Paxxil
    Mar 9, 2011 at 21:34
0

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.

1
  • Default on some systems, maybe. Others may be different. Mar 9, 2011 at 23:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .