Local time: Tue 2018-05-01 21:54:24 CST Universal time: Tue 2018-05-01 13:54:24 UTC RTC time: Tue 2018-05-01 13:54:24 Time zone: Asia/Shanghai (CST, +0800) Network time on: yes NTP synchronized: yes RTC in local TZ: no
如果上述显示输出中:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Local time: Fri 2021-05-28 16:24:59 CST Universal time: Fri 2021-05-28 08:24:59 UTC RTC time: Fri 2021-05-28 16:24:57 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: inactive RTC in local TZ: yes
Warning: The system is configured to read the RTC time in the local time zone. This mode cannot be fully supported. It will create various problems with time zone changes and daylight saving time adjustments. The RTC time is never updated, it relies on external facilities to maintain it. If at all possible, use RTC in UTC by calling 'timedatectl set-local-rtc 0'.
可以看到:
1
NTP service: inactive
实际上没有激活,所以我们通过以下命令激活:
1
timedatectl set-ntp true
然后再次检查 timedatectl status 可以看到:
1 2 3
... NTP service: active ...
此外,按照提示,关闭从本地时区读取 RTC 时间:
1
timedatectl set-local-rtc 0
完成后再次检查 timedatectl status 可以看到:
1 2 3 4 5 6 7
Local time: Fri 2021-05-28 16:29:18 CST Universal time: Fri 2021-05-28 08:29:18 UTC RTC time: Fri 2021-05-28 08:29:18 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no
● 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 2018-04-16 10:33:42 CST; 2 weeks 1 days ago Docs: man:systemd-timesyncd.service(8) Main PID: 910 (systemd-timesyn) Status: "Synchronized to time server 91.189.91.157:123 (ntp.ubuntu.com)." Tasks: 2 Memory: 2.2M CPU: 2.710s CGroup: /system.slice/systemd-timesyncd.service └─910 /lib/systemd/systemd-timesyncd
Apr 29 07:30:24 devstack systemd-timesyncd[910]: Timed out waiting for reply from 91.189.91.157:123 (ntp.ubuntu.com). Apr 29 07:30:24 devstack systemd-timesyncd[910]: Synchronized to time server 91.189.94.4:123 (ntp.ubuntu.com). Apr 29 09:14:36 devstack systemd-timesyncd[910]: Timed out waiting for reply from 91.189.94.4:123 (ntp.ubuntu.com). Apr 29 09:14:46 devstack systemd-timesyncd[910]: Timed out waiting for reply from 91.189.89.198:123 (ntp.ubuntu.com). Apr 29 09:14:56 devstack systemd-timesyncd[910]: Timed out waiting for reply from 91.189.89.199:123 (ntp.ubuntu.com). Apr 29 09:49:06 devstack systemd-timesyncd[910]: Synchronized to time server 91.189.89.199:123 (ntp.ubuntu.com). Apr 29 13:52:01 devstack systemd-timesyncd[910]: Timed out waiting for reply from 91.189.89.199:123 (ntp.ubuntu.com). Apr 29 13:52:11 devstack systemd-timesyncd[910]: Timed out waiting for reply from 91.189.89.198:123 (ntp.ubuntu.com). Apr 29 13:52:21 devstack systemd-timesyncd[910]: Timed out waiting for reply from 91.189.94.4:123 (ntp.ubuntu.com). Apr 29 13:52:22 devstack systemd-timesyncd[910]: Synchronized to time server 91.189.91.157:123 (ntp.ubuntu.com).
... May 01 22:38:36 pi1 systemd[1]: Starting Network Time Synchronization... May 01 22:38:37 pi1 systemd[1]: Started Network Time Synchronization. May 01 22:38:37 pi1 systemd-timesyncd[23922]: Synchronized to time server 192.168.6.11:123 (192.168.6.11).