我在运行 Ubuntu 17.04 和 Windows 7 的双启动笔记本电脑上。启动 Windows 会将 RTC 设置为本地时间,从而破坏 Ubuntu 中的系统时钟。
我不想更改 ubuntu 或 Windows 上的 RTC 配置;我希望 ubuntu 在有网络连接时立即将时间同步到网络。这以前是用 ntpdate(现在已弃用)完成的,据我所知,ubuntu 系统的当前配置使用 systemd-timesyncd。这不起作用,到目前为止,我无法强制 timesyncd 同步时间。
/etc/systemd/timesyncd.conf 设置为使用pool.ntp.org:
[Time]
NTP=0.pool.ntp.org
FallbackNTP=1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org
但是,systemd 状态显示 timesyncd 无法连接到 pool.ntp.org:
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
└─disable-with-time-daemon.conf
Active: active (running) since Mon 2017-08-07 10:13:38 PDT; 1min 44s ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 986 (systemd-timesyn)
Status: "Idle."
Tasks: 2 (limit: 4915)
CGroup: /system.slice/systemd-timesyncd.service
└─986 /lib/systemd/systemd-timesyncd
Aug 07 10:13:37 rachael systemd[1]: Starting Network Time Synchronization...
Aug 07 10:13:38 rachael systemd[1]: Started Network Time Synchronization.
Aug 07 10:14:48 rachael systemd-timesyncd[986]: Timed out waiting for reply from 204.2.134.163:123 (0.pool.ntp.org).
Aug 07 10:14:59 rachael systemd-timesyncd[986]: Timed out waiting for reply from 91.224.149.41:123 (0.pool.ntp.org).
Aug 07 10:15:09 rachael systemd-timesyncd[986]: Timed out waiting for reply from 103.242.70.5:123 (0.pool.ntp.org).
Aug 07 10:15:19 rachael systemd-timesyncd[986]: Timed out waiting for reply from 178.62.16.103:123 (0.pool.ntp.org).
这可能是因为 timesyncd 依赖于 networkd,但由于 ubuntu 使用 network-manager 来处理其连接,因此 networkd 被禁用:
● systemd-networkd.service - Network Service
Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-networkd.service(8)
顺便说一句,timedated 也被禁用了(不知道这是否相关):
● systemd-timedated.service - Time & Date Service
Loaded: loaded (/lib/systemd/system/systemd-timedated.service; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-timedated.service(8)
man:localtime(5)
http://www.freedesktop.org/wiki/Software/systemd/timedated
因此,timedatectl 将 ntp sync 列为已禁用,与配置文件的内容无关:
Local time: Mon 2017-08-07 10:27:48 PDT
Universal time: Mon 2017-08-07 17:27:48 UTC
RTC time: Mon 2017-08-07 17:27:48
Time zone: America/Los_Angeles (PDT, -0700)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
尝试手动启用 timesyncd 上的 ntp 同步没有效果。即:
# timedatectl set-ntp true
什么也没做。
网络时间同步在较新的 Ubuntu 系统中如何工作?