如何检查 Ubuntu 18.04 中 NTP 是否已启用

如何检查 Ubuntu 18.04 中 NTP 是否已启用

我已经安装了 chrony 并尝试从配置的 NTP 池中获取时间。并且我已经在 timedatectl 上启用了 NTP。但是我如何确保我在“date/timedatectl”命令上看到的时间是从 NTP 服务器获取的。在 Ubuntu 18.04 上timedatectl命令未显示 NTP 同步详细信息。

/etc/chrony/chrony.conf

pool time.google.com prefer iburst
keyfile /etc/chrony/chrony.keys
commandkey 1
driftfile /var/lib/chrony/chrony.drift
log tracking measurements statistics
logdir /var/log/chrony
maxupdateskew 100.0
dumponexit
dumpdir /var/lib/chrony
dumpdir /var/lib/chrony
logchange 0.5
hwclockfile /etc/adjtime
rtcsync
root@server-2:~# systemctl status chronyd
● chrony.service - chrony, an NTP client/server
   Loaded: loaded (/lib/systemd/system/chrony.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-11-11 12:16:13 IST; 43min ago
     Docs: man:chronyd(8)
           man:chronyc(1)
           man:chrony.conf(5)
  Process: 6228 ExecStartPost=/usr/lib/chrony/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 6202 ExecStart=/usr/lib/systemd/scripts/chronyd-starter.sh $DAEMON_OPTS (code=exited, status=0/SUCCESS)
 Main PID: 6226 (chronyd)
    Tasks: 1 (limit: 2318)
   CGroup: /system.slice/chrony.service
           └─6226 /usr/sbin/chronyd

Nov 11 12:16:13 server-2 systemd[1]: Starting chrony, an NTP client/server...
Nov 11 12:16:13 server-2 chronyd[6226]: chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SECHASH 
Nov 11 12:16:13 server-2 chronyd[6226]: commandkey directive is no longer supported
Nov 11 12:16:13 server-2 chronyd[6226]: Frequency -88.224 +/- 0.493 ppm read from /var/lib/chrony/chrony.drift
Nov 11 12:16:13 server-2 systemd[1]: Started chrony, an NTP client/server.
sudo timedatectl set-ntp true
root@server-2:~# timedatectl 
                      Local time: Wed 2020-11-11 13:04:58 IST
                  Universal time: Wed 2020-11-11 07:34:58 UTC
                        RTC time: Wed 2020-11-11 07:34:58
                       Time zone: Asia/Kolkata (IST, +0530)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no
root@server-2:~# 

没有提供 NTP 同步的详细信息timedatectl输出。那么我们如何确认 ntp 是否已启用以及 timedatectl 是否与 NTP 服务器同步。

答案1

要查看 chrony 同步时钟的努力的当前状态,请从 和chronyc -n tracking开始chronyc -n sources

相关内容