RTC and System clock not in sync

clocksuse

How to set the system clock sync with RTC (Hardware Clock / BIOS). I am writing a script that uses a system clock in order to start the system with alarm.

For this the sole requirement is to have a proper RTC clock. On my test system (SLES 10 SP4), I use NTP Server to manage the system clock. But the RTC clock is always ahead.

So for example : currently the system clock shows 14:00 26.05.2016 and the RTC shows 16:00 Hrs. I read the man pages of hwclock and it shows that following command

hwclock --systohc --localtime

would sync the RTC clock to system clock. Which it did.

But after a reboot/shutdown, when the system comes up again, the RTC is again messed up. So there is something more which controls the RTC when the system is rebooted.

Could someone point me in the right direction. Thanks in advance.

Best Answer

You can use the hwclock command to set the hardware clock.
From the man hwclock page :

 --set  Set the Hardware Clock to the time given by the --date option.

You can apply the current system time to the hw clock with :

hwclock -w

or even manually with :

hwclock --set --date "$(date)"

After you added details to your question, my answer is not enough though, so here are more details below.
You can check timezone with the timedatectl status command.
List timezones with timedatectl list-timezones.
You can set your timezone to UTC for example with timedatectl set-timezone UTC.
You will find more details about timezone settings here.

Related Question