如何在 Raspberry Pi 上启用或禁用 NTP 时间同步
禁用 NTP:
disable_ntp.sh
sudo systemctl disable --now systemd-timesyncd启用 NTP:
enable_ntp.sh
sudo systemctl enable --now systemd-timesyncd验证 NTP 是否活跃
你可以通过运行以下命令验证 NTP 是否活跃
timedatectl.txt
timedatectl然后查找这些行:
ntp_active.txt
System clock synchronized: yes
NTP service: activeSystem clock synchronized 会告诉你 NTP 服务是否已成功将系统时间同步到 NTP 时间服务器:yes 表示已同步,no 表示未同步。
NTP service 会告诉你 NTP 服务是否正在运行,即是否正在尝试将系统时间同步到 NTP 时间服务器:active 表示正在运行,inactive 表示未运行
NTP 活跃时的输出:
timedatectl_ntp_active.txt
Local time: Tue 2023-03-14 16:49:28 CET
Universal time: Tue 2023-03-14 15:49:28 UTC
RTC time: Tue 2023-03-14 15:49:28
Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: yes
NTP service: active
RTC in local TZ: noNTP 不活跃时的输出:
ntp_inactive.txt
Local time: Tue 2023-03-14 16:48:01 CET
Universal time: Tue 2023-03-14 15:48:01 UTC
RTC time: Tue 2023-03-14 15:48:01
Time zone: Europe/Berlin (CET, +0100)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: noCheck out similar posts by category:
Linux, Raspberry Pi
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow