在 Arch Linux 中重启后更改了 UTC 时间转储

在 Arch Linux 中重启后更改了 UTC 时间转储

我使用带有 Linux 5.4.61-1-lts 内核的 Arch Linux 操作系统,x86-64。

我注意到,我的 UTC 时间是错误的:

[tao@dc ~]$ timedatectl
               Local time: Sun 2020-08-30 12:15:41 EEST 
           Universal time: Sun 2020-08-30 09:15:41 UTC  
                 RTC time: Sun 2020-08-30 09:15:41      
                Time zone: Europe/Chisinau (EEST, +0300)
System clock synchronized: no                           
              NTP service: inactive                     
          RTC in local TZ: no 

尽管这里我看到的是 06:15:41。

我发现只有一种方法可以更改 UTC 时间 - 使用NTTP 协议

[tao@dc ~]$ sudo ntpd -qg
[sudo] password for tao: 
30 Aug 12:20:15 ntpd[3371]: ntpd [email protected] Wed Jul  1 17:02:17 UTC 2020 (1): Starting
30 Aug 12:20:15 ntpd[3371]: Command line: ntpd -qg
30 Aug 12:20:15 ntpd[3371]: ----------------------------------------------------
30 Aug 12:20:15 ntpd[3371]: ntp-4 is maintained by Network Time Foundation,
30 Aug 12:20:15 ntpd[3371]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
30 Aug 12:20:15 ntpd[3371]: corporation.  Support and training for ntp-4 are
30 Aug 12:20:15 ntpd[3371]: available at https://www.nwtime.org/support
30 Aug 12:20:15 ntpd[3371]: ----------------------------------------------------
30 Aug 12:20:15 ntpd[3371]: proto: precision = 0.232 usec (-22)
30 Aug 12:20:15 ntpd[3371]: basedate set to 2020-06-19
30 Aug 12:20:15 ntpd[3371]: gps base set to 2020-06-21 (week 2111)
30 Aug 12:20:15 ntpd[3371]: Listen and drop on 0 v6wildcard [::]:123
30 Aug 12:20:15 ntpd[3371]: Listen and drop on 1 v4wildcard 0.0.0.0:123
30 Aug 12:20:15 ntpd[3371]: Listen normally on 2 lo 127.0.0.1:123
30 Aug 12:20:15 ntpd[3371]: Listen normally on 3 wlp2s0 192.168.100.5:123
30 Aug 12:20:15 ntpd[3371]: Listen normally on 4 lo [::1]:123
30 Aug 12:20:15 ntpd[3371]: Listen normally on 5 wlp2s0 [fe80::5aee:76d3:f600:ccc7%3]:123
30 Aug 12:20:15 ntpd[3371]: Listening on routing socket on fd #22 for interface updates
30 Aug 09:20:21 ntpd[3371]: ntpd: time set -10800.518742 s
ntpd: time set -10800.518742s
[tao@dc ~]$ 

但问题是重启后这个更改会消失。我想永久更改 UTC 时间。我不想在启动时将脚本放在某个地方,我想解决这个问题。感谢您的阅读。

答案1

“世界时间”代表系统时钟,可以使用各种工具手动调整,例如date --utc --set="hh:mm"timedatectl set-time "hh:mm UTC"。你不需要使用 ntpd 来实现这一点,尽管使用 NTP比手工操作要准确得多。

但是为了保存您的更改,系统时钟需要在某个时间点写入 RTC(电池供电的硬件时钟)。

如果您保持 NTP 守护程序运行,RTC 将每 11 分钟自动更新一次。(使用 ntpd 或 systemd-timesyncd 时始终如此,但使用 chrony 时需要“rtctrim”选项。)对于便携式系统,我建议启用以systemd-timesyncd.service处理时钟同步。

如果您不想一直运行 NTP,则hwclock --systohc每次调整系统时钟时,您都需要运行以将系统时钟保存在 RTC 中。

答案2

谢谢您的回答,user1686。您给了我很好的提示。

我解决了这个问题。我做了以下事情:

$ sudo ntpd -qg
$ GRUB_CMDLINE_LINUX_DEFAULT="clocksource=hpet"
$ su
# grub-mkconfig -o /boot/grub/grub.cfg
# reboot

希望这对某人有帮助。谢谢帮助。

更新:该解决方案不起作用。

相关内容