有了ntp
,我可以运行ntpq -p
来查看时钟精度的当前状态。新服务有同等功能吗systemd-timesyncd
?
我查看了该timedatectl
命令,它给了我以下选项:
$ timedatectl --help
timedatectl [OPTIONS...] COMMAND ...
Query or change system time and date settings.
-h --help Show this help message
--version Show package version
--no-pager Do not pipe output into a pager
--no-ask-password Do not prompt for password
-H --host=[USER@]HOST Operate on remote host
-M --machine=CONTAINER Operate on local container
--adjust-system-clock Adjust system clock when changing local RTC mode
Commands:
status Show current time settings
set-time TIME Set system time
set-timezone ZONE Set system time zone
list-timezones Show known time zones
set-local-rtc BOOL Control whether RTC is in local time
set-ntp BOOL Enable or disable network time synchronization
也许有一个文件我可以查看?
我期待至少看到一些这样的数据:
$ sudo ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
monster .INIT. 16 u - 64 0 0.000 0.000 0.000
ntp.ucdavis.edu 128.9.176.30 2 u 4 64 1 19.383 -19.799 0.000
45.207.161.200 .INIT. 16 u - 64 0 0.000 0.000 0.000
time-b-wwv.nist .NIST. 1 u 3 64 1 46.721 2.287 0.000
198.255.68.106 172.89.18.234 2 u 3 64 1 29.467 0.775 0.000
euphoric.ca 128.233.154.245 2 u 3 64 1 55.963 2.732 0.000
user-69-1-1-251 216.239.35.0 2 u 3 64 1 106.202 11.649 0.000
tick.chi1.ntfo. 206.55.64.77 3 u 4 64 1 61.316 -3.556 0.000
答案1
当前版本timedatectl
有两个子命令,可用于显示有关system-timesyncd
SNTP(简单网络时间协议)客户端服务的信息。
SNTP 客户端比 NTP 客户端更简单、更简约,因为它绕过了各种步骤,不保存那么多同步信息,仅定期调整系统时间,因此不太准确。ntpq
不适用于 SNTP。
# timedatectl timesync-status -a
Server: 162.159.200.1 (0.fedora.pool.ntp.org)
Poll interval: 4min 16s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 3
Reference: A230E10
Precision: 1us (-25)
Root distance: 24.711ms (max: 5s)
Offset: -609us
Delay: 36.883ms
Jitter: 211.500ms
Packet count: 384
Frequency: +10.723ppm
# timedatectl show-timesync -a
LinkNTPServers=
SystemNTPServers=
FallbackNTPServers=0.fedora.pool.ntp.org 1.fedora.pool.ntp.org 2.fedora.pool.ntp.org 3.fedora.pool.ntp.org
ServerName=0.fedora.pool.ntp.org
ServerAddress=162.159.200.1
RootDistanceMaxUSec=5s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=4min 16s
NTPMessage={ Leap=0, Version=4, Mode=4, Stratum=3, Precision=-25, RootDelay=48.660ms, RootDispersion=381us, Reference=A230E10, OriginateTimestamp=Thu 2021-02-18 04:47:25 GMT, ReceiveTimestamp=Thu 2021-02-18 04:47:25 GMT, TransmitTimestamp=Thu 2021-02-18 04:47:25 GMT, DestinationTimestamp=Thu 2021-02-18 04:47:26 GMT, Ignored=no PacketCount=384, Jitter=211.500ms }
Frequency=702740
#
如果您想持续监控服务的状态systemd-timesyncd
,可以使用timedatectl timesync-status --monitor
。
systemd-timesyncd
您可以使用--property=
或选项显示服务的各个属性-p
。例如:
# timedatectl show-timesync -p ServerName
ServerName=0.fedora.pool.ntp.org
#