Most of us set and synchronize our clocks using NTP (Network Time Protocol) or the program named xntpd. This program is really heavy duty in the sense that it is designed for large networks and designed to synchronize down to milliseconds or better. Consequently, it is a bit picky about running under conditions which are not ideal. This is OK, even highly desirable for large sophisticated networks, but I'm happy if my computer clocks are within one second of each other. One consequence of the picky behavior of xntpd is that it will not reset a clock that is off more than a certain amount (one hour I think), and if it cannot reset the clock, it will stop running.
One solution to this problem would be to modify the xntpd code to be more forgiving for less "serious" site such as mine. The other solution is to write a watchdog program, which I did, that examines the situation periodically (hourly at my site) and if it finds a problem, it attempts to fix it and emails the administrator a report. I call the program check.saneDate.hourly and drop it into my /etc/cron.hourly directory where it automatically runs once an hour (on RedHat systems -- no need to mess with cron). To avoid an avalanche of email, if you have one or more servers stop and you are away for awhile, the program places a limit on the number of emails sent (default 10).
This program is a Perl script. To make it work, you will probably need to change some of the configuration statements that specify program locations, and you will need to change the first line that specifies where to execute Perl. Here are the first few lines of documentation of the program.
# Program to do a sanity check on the local clock's time and date.
# Many if not most Unix based Web sites use ntp to synchronize their
# clock with that of a stratum 2 time server. ntp does a good job,
# but if for some reason, your clock differs significantly (about
# one hour), ntp will stop functioning, and on my machine, it even
# exits, thus leaving you with an unsynchronized clock. This
# typically happens during spring and fall daylight savings time
# changes. This program is meant to correct those situations and
# ensure that ntp is running and that your clock stays within
# reasonable sync with the external servers.
# This program is in the public domain.
#
# Assumptions:
# 1. You are running NTP (tested with xntp3-5.93-4 and xntp3-5.93-12)
# 2. The program ntpq is available
# 3. The program ntpdate is available
# 4. This Perl program is run once an hour
# 5. This program always restarts NTP if it thinks it is not running.
# 6. This program leaves files in the /tmp directory when it detects
# a problem. When all is OK, they are removed. If you automatically
# remove files from /tmp, you may want to put these files elsewhere.
# If they are removed, the worst that will happen is that you will
# miss sync warning messages, and you may get more email than
# you expected.
Home: www.sibbald.com
Contact: kern at sibbald dot com
Last Update: