I’m using manjaro linux on a lenovo laptop. In KDE time setting, the set date and time automatically option enabled.
When I open the laptop lid, the laptop wake from sleep state. And the system time randomly goes wrong.
Today is 2024.02.05, but the system time show the time is in 2078-03-11. After I reboot the system, the time is back to right.
Below are some logs:
Kernel version:
➜ ~ uname -a
Linux lj-82y8 6.6.10-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri Jan 5 17:38:36 UTC 2024 x86_64 GNU/Linux
time info:
➜ ~ timedatectl
Local time: 五 2078-03-11 10:46:42 CST
Universal time: 五 2078-03-11 02:46:42 UTC
RTC time: 一 2024-02-05 01:32:45
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
➜ ~ sudo hwclock --verbose
hwclock from util-linux 2.39.3
System Time: 3414192410.960293
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1706183195 seconds after 1969
Last calibration done at 1706183195 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: 2024/02/05 01:32:55
Hw clock time : 2024/02/05 01:32:55 = 1707096775 seconds since 1969
Time since last adjustment is 913580 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2024-02-05 09:32:54.154743+08:00
and also I use the ntpd -qg the time also goes to be right
➜ ~ sudo ntpd -qg
11 Mar 10:48:55 ntpd[14790]: ntpd 4.2.8p17@1.4004-o Tue Jun 6 14:05:47 UTC 2023 (1): Starting
11 Mar 10:48:55 ntpd[14790]: Command line: ntpd -qg
11 Mar 10:48:55 ntpd[14790]: ----------------------------------------------------
11 Mar 10:48:55 ntpd[14790]: ntp-4 is maintained by Network Time Foundation,
11 Mar 10:48:55 ntpd[14790]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
11 Mar 10:48:55 ntpd[14790]: corporation. Support and training for ntp-4 are
11 Mar 10:48:55 ntpd[14790]: available at https://www.nwtime.org/support
11 Mar 10:48:55 ntpd[14790]: ----------------------------------------------------
11 Mar 10:48:55 ntpd[14790]: DEBUG behavior is enabled - a violation of any
11 Mar 10:48:55 ntpd[14790]: diagnostic assertion will cause ntpd to abort
11 Mar 10:48:55 ntpd[14790]: proto: precision = 0.040 usec (-24)
11 Mar 10:48:55 ntpd[14790]: basedate set to 2023-05-25
11 Mar 10:48:55 ntpd[14790]: gps base set to 2023-05-28 (week 2264)
11 Mar 10:48:55 ntpd[14790]: Listen and drop on 0 v6wildcard [::]:123
11 Mar 10:48:55 ntpd[14790]: Listen and drop on 1 v4wildcard 0.0.0.0:123
11 Mar 10:48:55 ntpd[14790]: Listen normally on 2 lo 127.0.0.1:123
11 Mar 10:48:55 ntpd[14790]: Listen normally on 3 wlp1s0 192.168.218.245:123
11 Mar 10:48:55 ntpd[14790]: Listen normally on 4 lo [::1]:123
11 Mar 10:48:55 ntpd[14790]: Listen normally on 5 wlp1s0 [2409:895e:de7c:5593:1bc1:c833:7803:5a03]:123
11 Mar 10:48:55 ntpd[14790]: Listen normally on 6 wlp1s0 [fe80::db77:3b51:f040:e616%2]:123
11 Mar 10:48:55 ntpd[14790]: Listening on routing socket on fd #23 for interface updates
5 Feb 09:35:07 ntpd[14790]: ntpd: time set -1707095636.715332 s
ntpd: time set -1707095636.715332s
I don’t know why this happens and how can I solve this?
I like configuring a script to sync time according to network on every net connection.
(which, depending on configuration, would also fire after sleep/suspend)
Thanks for the reply, I just check the BIOS, the time is correct. What should I do to make sure the BIOS/UEFI issue? BTW, it is a new laptop, I just buy it two weeks ago.
This issue only happens when the laptop wake up after long(1 hour or longer sleep).
What does the Manjaro Settings Manager (manjaro-settings-manager) show when you open it and select the “Time and Date” section? This is what my system, which always has the correct time (even after sleeping), shows:
Thank you all guys. I think this is not a hardware problem.
I use two script to solve this. First script: /lib/systemd/system-sleep/time-shift
#!/bin/sh
case $1/$2 in
pre/*)
date +%s >> /tmp/suspend.log
;;
post/*)
date +%s >> /tmp/wakeup.log
hwclock --hctosys
date +%s >> /tmp/wakeup_shifted.log
;;
esac
second script:
➜ ~ cat /etc/NetworkManager/dispatcher.d/09-synctime
#!/bin/sh
case "$2" in
up)
date +%s > /tmp/before_ntp.log
ntpd -qg
date +%s > /tmp/after_ntp.log
;;
esac