systemd-timesyncd 服务正在空闲状态运行并且不同步时间

Mat*_*ias 2 sync time ntp services 16.04

我正在尝试将运行 Ubuntu 16.04.3 LTS 的英特尔 NUC 上的时间与在 Windows PC 上运行的 NTP 服务器同步。

\n\n

我已经检查了 NTP 服务器是否正常运行。

\n\n

在我看来,好像服务没有从配置文件中读取/etc/systemd/timesyncd.conf

\n\n

输出timedatectl status

\n\n
      Local time: Wed 2019-01-16 21:32:01 CET\n  Universal time: Wed 2019-01-16 20:32:01 UTC\n        RTC time: Wed 2019-01-16 20:32:01\n       Time zone: Europe/Vienna (CET, +0100)\n Network time on: yes\nNTP synchronized: no\n RTC in local TZ: no\n
Run Code Online (Sandbox Code Playgroud)\n\n

systemctl status systemd-timesyncd紧接着的输出systemctl restart systemd-timesyncd

\n\n
\xe2\x97\x8f systemd-timesyncd.service - Network Time Synchronization\n   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor pr\n  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d\n           \xe2\x94\x94\xe2\x94\x80disable-with-time-daemon.conf\n   Active: active (running) since Wed 2019-01-16 21:36:08 CET; 11s ago\n     Docs: man:systemd-timesyncd.service(8)\n Main PID: 2316 (systemd-timesyn)\n   Status: "Idle."\n   CGroup: /system.slice/systemd-timesyncd.service\n           \xe2\x94\x94\xe2\x94\x802316 /lib/systemd/systemd-timesyncd\n\nJan 16 21:36:08 coretv systemd[1]: Starting Network Time Synchronization...\nJan 16 21:36:08 coretv systemd[1]: Started Network Time Synchronization.\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的配置文件在/etc/systemd/timesyncd.conf

\n\n
#  This file is part of systemd.\n#\n#  systemd is free software; you can redistribute it and/or modify it\n#  under the terms of the GNU Lesser General Public License as published by\n#  the Free Software Foundation; either version 2.1 of the License, or\n#  (at your option) any later version.\n#\n# Entries in this file show the compile time defaults.\n# You can change settings by editing this file.\n# Defaults can be restored by simply deleting this file.\n#\n# See timesyncd.conf(5) for details.\n\n[Time]\nNTP=192.168.20.1\n#FallbackNTP=ntp.ubuntu.com\n
Run Code Online (Sandbox Code Playgroud)\n\n

如果发生任何更改,所有命令都会以 root 身份通过 ssh 连接运行。

\n\n

我缺少什么吗?

\n\n
\n\n

编辑:

\n\n

我没有时间再考虑这个问题了。我将使用一种解决方法,这样我就不必依赖系统时间。

\n\n

仍然感谢答案,因为解决这个问题将是一个更干净的解决方案。

\n

小智 6

我意识到这是一个旧线程,但最近我遇到了完全相同的问题,我想分享我的解决方案,以便其他人可以避免花费数小时试图解决它。

对我来说,问题出在 timesyncd.conf 中的 RootDistanceMaxSec 参数。默认为5秒;然而,当在 Wireshark 中查看 NTP 数据包时,根分散值约为 10 秒。我相信 systemd-timesyncd 忽略了所有 NTP 数据包,因为根分散值高于最大值。

为了解决这个问题,我修改了 timesyncd.conf,取消注释以 RootDistanceMaxSec 开头的行,并将该值更新为比我在 NTP 数据包中看到的根分散值大几秒的数字。然后我重新启动了系统,一切正常。

希望这可以帮助那里的人节省几个小时。