.
contact contact

After reboot, the Linux system time is always wrong

 
.
 

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:

  1. 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.
  2. Delete the /etc/adjtime file.
  3. Use the date command to adjust the system's date/time (date MMDDhhmm[[CC]YY][.ss] - see man date).
  4. 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).
 
 
.
 
 
  Privacy | Webmaster | Terms of use | Impressum Revision:   
  Copyright © 1995-2002 Marxmeier Software AG