date and hwclock not in sync - why
Solution 1
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.
Solution 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.
Related videos on Youtube
Noob
Updated on September 18, 2022Comments
-
Noob over 1 year
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.
-
Noob almost 9 yearsproblem 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 almost 9 yearscan 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 almost 9 yearstried but failed. please take a look at original post, i have edited
-
Benyamin Jafari almost 6 yearsnot worked for me. when I get
hwclock --show
returned 1970, and withdate
I get 2018! -
Benyamin Jafari almost 6 yearsI synchronized
date
andhwclock
with this command:$ hwclock --systohc