我正在研究如何在 Ubuntu 22.04 中同步时间。与任何 systemd 控制的系统一样,该服务正在使用systemd-timesyncd
。
根据文档,启动时,systemd-timesyncd 将从以下位置读取配置文件/etc/systemd/timesyncd.conf
不可能,/etc/systemd/timesyncd.conf
因为其中的所有值都被注释掉了:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the timesyncd.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See timesyncd.conf(5) for details.
[Time]
#NTP=
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
所有内容都注释掉了,但当我查询 timedatectl 时,我可以看到 npt 等的值。老天爷,我真不明白 timesync 是如何获得它的值的。
># timedatectl show-timesync
FallbackNTPServers=ntp.ubuntu.com
ServerName=ntp.ubuntu.com
ServerAddress=185.125.190.56
RootDistanceMaxUSec=5s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=32s
NTPMessage={ Leap=0, Version=4, Mode=4, Stratum=2, Precision=-25, RootDelay=1.129ms, RootDispersion=213us, Reference=11FD1CFD, OriginateTimestamp=Fri 2024-11-29 21:22:30 GMT, ReceiveTimestamp=Fri 2024-11-29 21:22:33 GMT, TransmitTimestamp=Fri 2024-11-29 21:22:33 GMT, DestinationTimestamp=Fri 2024-11-29 21:22:30 GMT, Ignored=no PacketCount=656, Jitter=252.712ms }
据我所知,提到的其余 conf 文件均不存在。在我发疯之前,有什么想法吗?
后备 NTP 服务器是在构建时设置的,请参阅中的定义
DEFAULT_NTP_SERVERS
debian/rules
:时间值在代码中有默认值,请参阅
src/timesync/timesyncd-manager.h
: