[NTLUG:Discuss] clock issues

Stephen Klein klein at kbwireless.com
Fri May 27 16:05:49 CDT 2005


Fred James wrote:
> The box (info below) never seemed to be able to keep time, no matter how 
> I set it (Mandrake Control Center, or command line).  Synchronizing with 
> another server is not an option.  I was just about to change the 
> battery, before exploring the MiniHOWTO on Clock, when I noticed 
> something that I don't know why I didn't see it before.
> 
> I could set the time, and within a very short time the time was fast by 
> about 2 minutes - very repeatable - so the problem was in the hardware 
> and software clocks being out of sync
> 
> 'hwclock --show;date' proved this to be true.
> 'hwclock --set --date="n/nn/nn nn:nn:nn"' set the hardware clock to the 
> correct time (close enough anyway)
> 'hwclock --show;date' proves the two are now in sync.
> 
> Regards
> Fred James
> 
> 
> Dell Dimension XPS T700r
> Intel Pentium III Model 8 (Coppermine) 700 MHz
> Mandriva (Mandrake) 9.1
> 
> 
> _______________________________________________
> https://ntlug.org/mailman/listinfo/discuss
> 
> 

I was kinda in this boat about a year ago, then I went overkill and 
built myself a GPS refclock so that my clock is always correct.  Now 
that I have an always on broadband connection to the Internet, it's 
really overkill.

If the drift rate of your clock is fairly constant, you can use the 
--adjust of hwclock to figure out how much time to add or subtract.

The way it is supposed to work, you set the clock to the correct time 
using hwclock --set, and then wait a couple of weeks and then set it 
again using hwclock --set.  Doing this, hwclock will be able to 
calculate the drift rate of your clock fairly accurately and then store 
the result in /etc/adjtime.  The next time you want to set your clock 
(preferably after SEVERAL days, not two or three) just run adjtime -a, 
and it will use the drift information in /etc/adjtime to calculate an 
offset from the current time and apply the correction.

This will work fairly well if the system is powered all the time, and at 
a fairly constant temperature.  Temperature changes in my house during 
the summer are what prevented me from using this method.

One alternative you an use, but it takes a while to get calibrated, is 
to use a LOCAL refclock with NTP and manually adjust the drift rate 
stored in the drift file (usually /etc/ntp.drift).  I have to do this at 
work since I have been unable to convince those who control the firewall 
to open up port 123, and asking about a reference clock just leads to 
big question marks over their heads.  But, doing this, I'm able to 
maintain the clocks of my servers to within a few seconds of correct time.

The only alternative I know of is to build yourself a refclock that NTP 
will work with.  This can get complicated, but it does make for an 
interesting project.

Stephen




More information about the Discuss mailing list