挂起后设置系统时间

挂起后设置系统时间

唤醒后(关机/注销>暂停后)系统时间错误(无论是将来的还是过去的)。

$ systemctl restart systemd-timesyncd.service

让它再次正确。每次挂起后,有没有办法自动运行 systemctl?下面是我在唤醒后立即看到的内容(在运行 systemctl 之前)

$ sudo systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-06-14 14:57:45 EEST; 2 days left
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 6853 (systemd-timesyn)
     Status: "Initial synchronization to time server 91.198.10.4:123 (0.debian.pool.ntp.org)."
      Tasks: 2 (limit: 3678)
     Memory: 1.0M
        CPU: 116ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─6853 /lib/systemd/systemd-timesyncd

Jun 14 14:57:45 ambler systemd[1]: Starting Network Time Synchronization...
Jun 14 14:57:45 ambler systemd[1]: Started Network Time Synchronization.
Jun 11 18:57:46 ambler systemd-timesyncd[6853]: Initial synchronization to time server 91.198.10.4:123 (0.debian.pool.ntp.org).

使用:

AMD A6-5400K APU with Radeon Version E7792AMS V2.2.
Debian GNU/Linux 11 (bullseye)
GNOME Version 3.38.5

更新

我发帖的第二天就是系统更新,我以为问题解决了,今天(2022-02-22)又出现了。

$ sudo systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-06-17 17:18:24 EEST; 4 days ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 342 (systemd-timesyn)
     Status: "Initial synchronization to time server 31.28.161.68:123 (0.debian.pool.ntp.org)."
      Tasks: 2 (limit: 3678)
     Memory: 1.3M
        CPU: 377ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─342 /lib/systemd/systemd-timesyncd

Jun 17 17:18:24 ambler systemd[1]: Starting Network Time Synchronization...
Jun 17 17:18:24 ambler systemd[1]: Started Network Time Synchronization.
Jun 17 17:18:55 ambler systemd-timesyncd[342]: Initial synchronization to time server 162.159.200.123:123 (2.debian.pool.ntp.org).
Jun 18 11:01:56 ambler systemd-timesyncd[342]: Initial synchronization to time server 31.172.141.230:123 (0.debian.pool.ntp.org).
Jun 18 18:44:17 ambler systemd-timesyncd[342]: Initial synchronization to time server 91.236.251.12:123 (0.debian.pool.ntp.org).
Jun 19 11:32:05 ambler systemd-timesyncd[342]: Initial synchronization to time server 91.219.60.18:123 (0.debian.pool.ntp.org).
Jun 20 11:17:16 ambler systemd-timesyncd[342]: Initial synchronization to time server 45.87.155.41:123 (0.debian.pool.ntp.org).
Jun 21 11:04:00 ambler systemd-timesyncd[342]: Initial synchronization to time server 31.28.161.68:123 (0.debian.pool.ntp.org).
(.venv39) vlz@ambler:~/.../ymail$ date
Tue 21 Jun 2022 11:21:22 PM EEST
(.venv39) vlz@ambler:~/.../ymail$ sudo systemctl restart systemd-timesyncd.service
(.venv39) vlz@ambler:~/.../ymail$ date
Wed 22 Jun 2022 10:27:46 AM EEST

更新二

The problem is still there. Had to check date after each reasume/suspend

$ date
Tue 28 Jun 2022 07:12:22 PM EEST
$ systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-06-21 23:22:10 EEST; 6 days ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 29744 (systemd-timesyn)
     Status: "Idle."
      Tasks: 2 (limit: 3678)
     Memory: 1.1M
        CPU: 284ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─29744 /lib/systemd/systemd-timesyncd
$ systemctl restart systemd-timesyncd.service
$ date
Sat 25 Jun 2022 11:15:02 AM EEST

更新三

我束手无策了。现在(没有暂停/恢复)发现互联网连接(通过 Wi-Fi)断了。我尝试重新连接,Wi-Fi 密码(正确的)被拒绝。我暂停了系统,然后恢复。一切又恢复正常了。那是什么?这一定与我在这篇文章中首先报告的日期差距有某种联系。

更新四

互联网访问消失,并通过暂停/恢复重新获得。发现 /proc/modules 是空的。

$ sudo lshw -c network
  *-network                 
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: enp1s0
       version: 06
       serial: 44:8a:5b:22:34:11
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.10.0-15-amd64 firmware=rtl8168e-3_0.0.4 03/27/12 latency=0 link=no multicast=yes port=twisted pair
       resources: irq:16 ioport:e000(size=256) memory:d0004000-d0004fff memory:d0000000-d0003fff
  *-network
       description: Wireless interface
       physical id: 1
       bus info: usb@1:4
       logical name: wlx2cd05ae20794
       serial: 2c:d0:5a:e2:07:94
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=ath9k_htc driverversion=5.10.0-15-amd64 firmware=1.4 ip=192.168.1.15 link=yes multicast=yes wireless=IEEE 802.11

更新 V

看来问题在 4 天后再次出现。2 天前进行了内核更新

$ date
Mon 04 Jul 2022 07:21:25 PM EEST
$ sudo systemctl status systemd-timesyncd.service
[sudo] password for vlz: 
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-06-28 11:03:08 EEST; 6 days ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 326 (systemd-timesyn)
     Status: "Idle."
      Tasks: 2 (limit: 3678)
     Memory: 1.0M
        CPU: 280ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─326 /lib/systemd/systemd-timesyncd

Jun 28 11:03:08 ambler systemd[1]: Starting Network Time Synchronization...
Jun 28 11:03:08 ambler systemd[1]: Started Network Time Synchronization.
Jun 28 11:03:39 ambler systemd-timesyncd[326]: Initial synchronization to time server 185.102.185.67:123 (2.debian.pool.ntp.org).
Jun 29 11:27:24 ambler systemd-timesyncd[326]: Initial synchronization to time server 162.159.200.1:123 (0.debian.pool.ntp.org).
Jun 30 11:18:38 ambler systemd-timesyncd[326]: Initial synchronization to time server 91.236.251.180:123 (0.debian.pool.ntp.org).
$ systemctl restart systemd-timesyncd.service
$ date
Fri 01 Jul 2022 11:37:54 AM EEST

更新 VI

systemctl restart 不能修复时间,但 systemctl status 可以。

$ date
Tue 05 Jul 2022 07:43:54 PM EEST
$ systemctl restart systemd-timesyncd.service
$ date
Tue 05 Jul 2022 07:44:55 PM EEST
$ sudo systemctl status systemd-timesyncd.service
[sudo] password for vlz: 
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-07-05 19:44:50 EEST; 3 days left
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 40834 (systemd-timesyn)
     Status: "Initial synchronization to time server 62.149.0.30:123 (0.debian.pool.ntp.org)."
      Tasks: 2 (limit: 3678)
     Memory: 1.1M
        CPU: 66ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─40834 /lib/systemd/systemd-timesyncd

Jul 05 19:44:50 ambler systemd[1]: Starting Network Time Synchronization...
Jul 05 19:44:50 ambler systemd[1]: Started Network Time Synchronization.
Jul 05 19:45:00 ambler systemd-timesyncd[40834]: Timed out waiting for reply from 91.198.10.4:123 (0.debian.pool.ntp.org).
Jul 02 11:45:00 ambler systemd-timesyncd[40834]: Initial synchronization to time server 62.149.0.30:123 (0.debian.pool.ntp.org).
$ date
Sat 02 Jul 2022 11:51:01 AM EEST

更新七 收到以下错误:

$ sudo hwclock --get
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Invalid argument

它和原始问题有某种联系吗?

更新日期 10/26

GNOME 3 标题栏:关机/注销 -> 挂起偶尔会重新启动系统。第一次发生这种情况时,我以为我按错了行。然后我每次都会仔细检查,并确定错误不是我的。

更新日期 10/27

与我使用的 realtek wifi 适配器相关的暂停/恢复 (firmware-realtek_20210315-3_all.deb)。有时它会停止工作(断开连接):

$ nmcli device | grep wlx
wlx2cd05ae20794          wifi      disconnected  --         
p2p-dev-wlx2cd05ae20794  wifi-p2p  disconnected  --

令人惊讶的是,Suspend/Resume 恢复了 realtek 的正常功能。系统重启也可以,但这更容易理解。

更新 11/15

比以前少见(我希望如此),但有时挂起/恢复后系统时间仍然不正确。但是,很快时间就会自行重新调整,而无需我运行 systemctl。我不记得以前见过这样的“自我调整”。非常像最近更新的版本。

更新日期 1/20/23

甚至更奇怪。许多

$ sudo systemctl restart systemd-timesyncd.service 
$ sudo systemctl restart systemd-timesyncd.service 
$ sudo systemctl restart systemd-timesyncd.service 
$ date
Mon 23 Jan 2023 08:46:01 AM EET

重启没有效果。之后我再次挂起机器并唤醒。时间到了。

# before suspend
$ date
Mon 23 Jan 2023 08:47:23 AM EET
# when wakeup
$ date
Fri 20 Jan 2023 12:48:24 PM EET

更新日期 5/9/23

“sudo sync” 仍然记得密码,尽管由于我暂停了机器,它持续了好几个小时。如果这不是一个功能,那么它就不可能与 CMOS 电池耗尽有关

更新日期:8/22/23 问题仍然存在。有时恢复后的时间正常。有时 Suspend 会重新启动或使机器崩溃,我尝试但未能找到是否崩溃。我确定的是,这取决于我使用的 WiFi 适配器。机器有

RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller

从未发生过崩溃。很长一段时间以来,我一直在使用 USB TL-WN821N。它经常崩溃。每隔一两次“暂停”就会重新启动机器。我是怎么发现的?几天前坏了。系统再也看不到它了,我不得不使用 RTL。

相关内容