3

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.

  • problem solved. i am running on esxi 5.5 with vmtool installed, it has a function call time synchronisation that will sync the guest os timing with the host. My host timing is off, hence the guest timing is off too. – Noob Aug 4 '15 at 18:24
2

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.

  • can you elaborate abit further, how does the system clock derive its timing to be 8 hours later from the hwclock ? isn't both of them in the same timezone already ? if hwclock is in UTC, and it is showing in my local timezone of SGT+8, that means its UTC timing is actually 02:14:36 AM SGT - 8 hours. If so, how can my system date be wrong as it will + 8 hours. – Noob Jul 30 '15 at 14:25
  • tried but failed. please take a look at original post, i have edited – Noob Aug 1 '15 at 8:22
  • not worked for me. when I get hwclock --show returned 1970, and with date I get 2018! – Benyamin Jafari Jun 18 '18 at 12:11
  • I synchronized date and hwclock with this command: $ hwclock --systohc – Benyamin Jafari Jun 18 '18 at 12:17
2

I synchronized date and hwclock with this command:

$ sudo hwclock --systohc

Above command writes date time to hwclock time.

NOTE: If you want write hwclock time to date time do it:

$ sudo hwclock --hctosys

For test:

$ sudo hwclock --show
$ date

NOTE: You can use hwclock -s instead of hwclock --hctosys and hwclock -w instead of hwclock --systohc.

systohc = system time to hardware time.
hctosys = hardware time to system time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.