Setting Your System Time
Copyright (C) 2001 by Steve Litt
Warning!!!
This is not the best way to set your system time. It is not even the recommended
way to set your system time. As a matter of fact, most documentation warns
you AGAINST setting your system time with the date command, which is what
this document discusses.
That being said, this is simple, and for small time adjustments, I personally
use it.
Setting Your System Time
-
Pull up http://www.time.gov in a java
enabled browser. The Java is necessary so that the website updates itself.
-
Run the date command to set the date to the time on the browser:
date -s "11/29/2001 13:36:30"
to set the time to 13:36:30 on 11/29/2001. Obviously set the command to
a slightly future time, wait for time.gov to catch up, then press the Enter
key.
-
Note that at this point your system clock is accurate.
-
Now it's time to fix your hardware clock.
-
Log in as root
-
/sbin/hwclock -r
-
/sbin/hwclock --adjust
-
/sbin/hwclock --systohc
-
Power down and power back up. Once again check your system time against
time.gov. It should be good to within a few seconds, and stay that way
for awhile (days or weeks).
A little explanation is in order.
System time runs off interrupts and is extremely accurate. The only
problem is that it doesn't work unless the operating system is working.
For times when the computer is down, the hardware clock must keep time.
Then, when the computer is booted, the hardware clock time is copied to
the system time. Naturally, part of an orderly shutdown is to copy the
system time to the hardware clock.
/sbin/hwclock -r
shows you the time according to the hardware clock. It will most likely
be wrong.
/sbin/hwclock --adjust
makes changes the hardware clock adjustment mechanism so that the hardware
clock more accurately follows system time.
/sbin/hwclock --systohc
sets the hardware clock to the system time.
Remember, date sets your system time, which is updated by interrupts
while the operating system is running. hwclock sets your hardware
clock, which is a digital watch type clock on your motherboard, which runs
continuously on battery power whether the system is running or not.
Other Time Setting Documentation
See man hwclock, man date, and man adjtimex for details
on Linux time. You'll notice that these man pages recommend against the
method I outlined above. I use my method because it's simple and for no
other reason.
There are also time howtos on the Internet.
See also: [ Linux Library | Troubleshooters.Com
| Email Steve Litt | Copyright
Notice ]
Copyright
(C)2001 by Steve Litt. -- Legal