[TriLUG] DATE problems

Jeremy P jeremyp at pobox.com
Mon Dec 17 13:26:50 EST 2001


On Mon, 17 Dec 2001, Vestal, Roy L. wrote:

> No I'm not talking about my personal life ;)  
> 
> I have a question on the date program. Everyday, I login and have to run
> date -s hh:mm:ss am/pm to set the clock. I have run this as root via su when
> logged in as me, as well as log in as root, but everyday I have to do this.
> Any one know what to look for, or am I doing this wrong?

If you just set the date with date -s, you're only setting the "system" or
kernel clock.  Your PC's hardware clock isn't changed.  A quick way to
remedy this is the command "/sbin/hwclock --systohc" which will copy the
system clock to the hardware clock.  This normally happens on shutdown,
but if you have an uncontrolled shutdown the hardware clock wouldn't be
reset.[1]

If your clocks seem to drift a lot, use the "adjust" function of hwclock
to adjust for systematic drift.  I run this command every hour, and it
works pretty well... it measures systematic drift (when you give it a
known value, with hwclock --systohc or hwclock --set).  Then, when you run
it every hour or whatever via cron, the hwclock will be kept up to
date.  See the manpage on hwclock.

If that's not precise enough for you, you'll want to use rdate to
periodically update the time from a clock server (but be sure to run
hwclock --systohc also, because rdate only sets the system/kernel clock.)
Or install ntp, which is the ultimate solution for keeping your clock
correct.  I have ntp on my servers, and it's wonderful, but somewhat of a
pain to configure.

--Jeremy

[1] DOS and Windows don't use a separate kernel clock; the time you see
in applications directly acccesses the system/BIOS clock.  So when you set
the system time in Windows, it IS setting the hardware time.




More information about the TriLUG mailing list