date and hwclock not in sync – why

Noob asked:

I am on GMT+8 and I set my hwlock to UTC.

[root@sjoam2 ~]# date
Sat Aug  1 16:32:04 SGT 2015
[root@sjoam2 ~]# hwclock --systohc --utc
[root@sjoam2 ~]# hwclock --debug
hwclock from util-linux-ng 2.17.2
Using /dev interface to clock.
Last drift adjustment done at 1438417931 seconds after 1969
Last calibration done at 1438417931 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2015/08/01 08:32:17
Hw clock time : 2015/08/01 08:32:17 = 1438417937 seconds since 1969
Sat 01 Aug 2015 04:32:17 PM SGT  -0.641290 seconds
[root@sjoam2 ~]# 

Seems fine.

hwclock debug is showing 08:32 UTC

— I am not so sure on the last sentence in hwclock –debug
(Sat 01 Aug 2015 04:32:17 PM SGT -0.641290 seconds)
whereby it shows the date in current timezone format (which is +8 hours) – i assume its fine

After reboot

[root@sjoam2 ~]# hwclock --debug
hwclock from util-linux-ng 2.17.2
Using /dev interface to clock.
Last drift adjustment done at 1438417931 seconds after 1969
Last calibration done at 1438417931 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2015/08/01 08:36:45
Hw clock time : 2015/08/01 08:36:45 = 1438418205 seconds since 1969
Sat 01 Aug 2015 04:36:45 PM SGT  -0.782726 seconds
[root@sjoam2 ~]# 

Still seems ok from hwclock –debug output
Hwclock = 08:36

— I am not so sure on the last sentence in hwclock –debug (Sat 01 Aug 2015 04:36:45 PM SGT -0.782726 seconds) whereby it shows the date in current timezone format (which is +8 hours) – i assume its fine

But look at date now

[root@sjoam2 ~]# date
Sun Aug  2 00:40:31 SGT 2015

It is adding another 8 hours to the correct time of the hwclock last output
Sat 01 Aug 2015 04:36:45 PM SGT + 8 more hours, which is adding a total of 16 hours to the UTC timing

How do i prevent that ? Where has my configurations gone wrong.

My answer:


Your hardware clock should be storing UTC time, but you forgot to use the -u option to tell hwclock this. For example,

hwclock -ru

Resetting the date and then running

hwclock -su

will resolve the problem.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.