systemd-timesyncd.service - 网络时间同步显示状态“初始同步到时间服务器”

systemd-timesyncd.service - 网络时间同步显示状态“初始同步到时间服务器”

时钟同步在 Ubuntu 18.04 和 20.04 中的工作方式是否不同?

我已经配置了与本地时间服务器的同步。在 Ubuntu 18.04 中配置时钟同步后,状态显示与时间服务器同步。但是,Ubuntu 20.04 中的状态为“初始时间同步到时间服务器...”。

为什么 Ubuntu 20.04 没有显示“已同步”状态?如果没有同步,该如何解决?

ubuntu 20.04 中的 systemd-timesyncd 状态:

$ systemctl status systemd-timesyncd

● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-03-18 23:17:29 IST; 2s ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 476708 (systemd-timesyn)
     Status: "**Initial synchronization to time server** <server_ip>."
      Tasks: 2 (limit: 19009)
     Memory: 1.2M
     CGroup: /system.slice/systemd-timesyncd.service
             └─476708 /lib/systemd/systemd-timesyncd

.. systemd[1]: Starting Network Time Synchronization...
.. systemd[1]: Started Network Time Synchronization.
.. systemd-timesyncd[476708]: Initial synchronization to time server 

ubuntu 18.04 中的 systemd-timesyncd 状态:

$ systemctl status systemd-timesyncd

● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2023-03-18 22:26:32 IST; 25min ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 7607 (systemd-timesyn)
   Status: " ** Synchronized to time server ** <server_ip>."
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/systemd-timesyncd.service
           └─7607 /lib/systemd/systemd-timesyncd

.. systemd[1]: Starting Network Time Synchronization...
.. systemd[1]: Started Network Time Synchronization.
.. systemd-timesyncd[7607]: Synchronized to time server

答案1

这是正常的 - 显然,团队将系统日志条目systemd中的措辞timesyncd从 Ubuntu 18.04 更改为 20.04。

timesyncd“初始同步到时间服务器”,则表示时间同步成功。

您可以timesyncd.service通过运行来确认是否正常工作并且时钟同步timedatectl status

您可以运行以获取有关当前时间服务器、同步等的更多信息timedatectl timesync-status

作为参考,这是我的机器执行所有命令的工作输出(我使用的是 Ubuntu 22.04,但输出应该类似)。

$ systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-03-18 23:17:15 CET; 22h ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 3727200 (systemd-timesyn)
     Status: "Initial synchronization to time server 192.36.143.130:123 (0.dk.pool.ntp.org)."
      Tasks: 2 (limit: 77001)
     Memory: 1.3M
        CPU: 594ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─3727200 /lib/systemd/systemd-timesyncd

Mar 18 23:17:14 xb systemd[1]: Starting Network Time Synchronization...
Mar 18 23:17:15 xb systemd[1]: Started Network Time Synchronization.
Mar 18 23:17:15 xb systemd-timesyncd[3727200]: Initial synchronization to time server 192.36.143.130:123 (0.dk.pool.ntp.org).

$ timedatectl status
               Local time: Sun 2023-03-19 22:01:55 CET
           Universal time: Sun 2023-03-19 21:01:55 UTC
                 RTC time: Sun 2023-03-19 21:01:55
                Time zone: Europe/Copenhagen (CET, +0100)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

$ timedatectl timesync-status                                                                                                │
       Server: 192.36.143.130 (0.dk.pool.ntp.org)                                                                              │
Poll interval: 34min 8s (min: 32s; max 34min 8s)                                                                               │
         Leap: normal                                                                                                          │
      Version: 4                                                                                                               │
      Stratum: 1                                                                                                               │
    Reference: PPS                                                                                                             │
    Precision: 1us (-25)                                                                                                       │
Root distance: 30us (max: 5s)                                                                                                  │
       Offset: +752us                                                                                                          │
        Delay: 15.248ms                                                                                                        │
       Jitter: 1.021ms                                                                                                         │
 Packet count: 44                                                                                                              │
    Frequency: +25.579ppm

相关内容