Hardware clock

Derek Martin dmartin at LanCity.COM
Sat Nov 20 13:06:05 EST 1999


On Fri, 19 Nov 1999 cprincipe at mindspring.com wrote:

> If you want a kludge when adjusting your time, you can adjust your
> time a couple of times in a row.  This alters the drift rate in
> /etc/adjustime (as far as I can tell.)

Yep.  I ended up figuring this out because I just had a similar problem
with my own RH 6.1 workstation.  All of a sudden, when you reboot your
system, the clock gets set to some strange time (in my case, exactly
1.5 hours fast), and despite resetting the time, after rebooting Linux 
it gets screwed up again... 

What you should do is this:


1) DELETE /etc/adjtime
2) Set the system time with 
   
  date -s 15:00   (this assumes it's 3pm - obviously use the right time!)

3) use the hwclock command to set the hardware clock, like this:

  hwclock --systohc

If your system is using UTC (Or Grenwich Mean Time as it was called
previously) be sure to also use the --utc option on hwclock.

Alternately, using 

  hwclock --set <time/date arg> 

a couple of times in succession should also work.


The problem was caused (at least in my case) by setting the time in a
manner not consistent with the way RH sets the system time (i.e. setting
the clock from the BIOS).

See the relevant discussion about the --adjtime option in the hwclock
manpage, and then look at /etc/rc.d/rc.sysinit to see what RH is doing to
set the clock, for specific details.

Basically, setting the system clock any way other than from Linux, using
hwclock screws up the system clock, because redhat adjusts the hardware
clock at boot time based on the difference between the system clock and
the hardware clock on two consecutive boots.  By setting the system clock
manually (from BIOS, or from within Windows), you completely hose that
scheme.

I don't particularly like the way RedHat does this by default, but so long
as you only change your hardware clock from Linux using hwclock, you will
never have any problem.  I do think they should ask you if you want to do
this when you install the system though... many Linux users are still
using multi-boot systems, and, for example, if you are in Windows when a
Daylight Savings Time change occurs and windows changes your clock, the
second time after that you boot into Linux your clock will be screwed up,
and most people will have no idea why...

Of course, this is probably mentioned in the Reference Guide, which
admittedly I did not read...  :)


-- 
Derek D. Martin
Senior UNIX Systems/Network Administrator
Arris Interactive
derek.martin at ne.arris-i.com

-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).



More information about the Discuss mailing list