|
Title: | After reboot, the Linux system time is always wrong |
Document: | 954237377 |
Author: | Roland Genske <rhg@marxmeier.com> |
Keywords: | Linux,system,date,time,reboot |
Q: After reboot, the Linux system time is always
wrong. This happened after I once adjusted the date/time
in the BIOS. I already changed the mainboard but the
situation did not change.
A: This is caused by the /etc/adjtime file
which is used to adjust the system clock's drift if you
don't use the NTP protocol for example to obtain the system
date/time from a time server.
Technical background: On systems with a reliable clock
reference (such as the TSC register in Pentium-class CPUs)
the difference between the elapsed time of the CPU and the
system clock is saved into the /etc/adjtime file.
This is used at the next reboot to adjust the system clock.
If you manually change the system date/time in the BIOS
you actually confuse this mechanism: A large drift value
will be written into /etc/adjtime which will cause
your system clock to become wrongly adjusted each time you
reboot.
Solution:
- Check if your system clock is kept in UTC (Universal
Coordinated Time). On SuSE Linux for example, this is
indicated with the GMT= variable in
/etc/rc.config:
If GMT="-u" your system clock is kept in UTC.
- Delete the /etc/adjtime file.
- Use the date command to adjust the system's
date/time (date MMDDhhmm[[CC]YY][.ss] - see
man date).
- Execute hwclock --systohc to write this
adjusted date/time into the system clock (if your system
clock is kept in UTC you should additionally specify the
--utc option).
Alternatively, you can simply delete the
/etc/adjtime file, shut-down your system and adjust
the date/time in the BIOS (according to UTC or not,
depending on your settings in /etc/rc.config).
|
|