Linux Clock

I have noticed that over the last two years or so, one of my Linux server’s clocks is constantly wrong. Sometimes, it’s off by as little as a minute, but sometimes it’s up to 20 minutes off. When I check it today, it was nearly an hour off. Since it runs many cron jobs, including sending some “reminder” emails to people to enter data into a database, it’s a problem.

Here are the steps I took to fix the problem.

First, I created a script, “clocksync.sh.” This is the contents:

ntpdate clock.redhat.com
/sbin/hwclock --systohc

Then I setup a cronjob to run this once a day. Even running it twice within 5 minutes, the time gets adjusted.

This has fixed the issue well enough, but does anyone know why or how the time could get off by so much? It’s a Dell 400SC server.

2 Replies to “Linux Clock”

  1. entries we always use in any installation we do:

    /usr/sbin/netdate ntp.xs4all.nl > /dev/null
    /sbin/hwclock –systohc

    in the crontab, pick any time I’d say. can be every day, weekday, minute etc. take your pick ….

    there is no general reason why the time drifts. it at least keeps the time correct.

Comments are closed.