hwclock, not in sync with system clock
My hardware clock keeps going out of sync. I set it to system time a few times, but it keeps going back to a 5hrs ahead state.
Is this normal? Could it make trouble? How come my system clock is functioning properly when my hardware clock isn't?
I do not know if it is normal, or not, because I do not know why the hardware clock should go crazy. If it's a hardware issue, you could use a software workaround until you fix it.
Thehwclock
command should do what you need. You can use it in the terminal, as root, in order to set the system clock from the hardware clock, or to set the hardware clock from the system clock (depending on which one is more reliable):
hwclock --hctosys
or
hwclock --systohc
From the hwclock
man page:
-s, --hctosys
Set the System Time from the Hardware Clock.
[...] This is a good option to use in one of the system startup
scripts.
-w, --systohc
Set the Hardware Clock to the current System Time.
The system clock gets set to either UTC or Local based on the last option used when the hwclock function was run. If you run:
hwclock -w --localtime
This should write your system clock to local time instead of UTC and should subsequently set it and read it at boot using local time. If you manually set your system clock and the hwclock was last specified with UTC then it will automatically set it back to UTC.
If it is always exactly 5 hours ahead it sounds like a timezone issue. In which case, it's likely that your hardware clock is set to local time, while the Linux system time is always set to UTC. If your timezone is 5 hours off of UTC, that would be the 5 hours.
In which case, in addition to the "--systohc" options for "hwclock" you should look into the "--localtime" and "--utc" options.