RPi 作業系統的 ntp service 相關

查詢系統的自動同步時間服務
$ sudo systemctl status ntp.service  # 是否正常執行中
$ sudo systemctl stop ntp.service  # 停止
$ sudo systemctl start ntp.service  # 執行
$ sudo systemctl restart ntp.service  # 重新執行
$ sudo systemctl disable ntp.service  # 停用
$ sudo systemctl enable ntp.service  # 啟用

查詢 ntp 設定檔
$ cat /etc/ntp.conf
# 使用 chronyd 的話
$ cat /etc/chrony/chrony.conf
# 或是
$ less /etc/ntp.conf  # note: press q to exit

也可以使用以下命令直接查詢正在使用的 NTP 伺服器。這會向 NTP 伺服器發送查詢並顯示響應
$ ntpd -pdn
# 使用 chronyd 的話
$ chronyc sources

修改 ntp 設定檔
$ sudo nano /etc/ntp.conf
加進多個 pool
pool 1.tw.pool.ntp.org iburst
pool 2.pool.ntp.org iburst
pool 0.tw.pool.ntp.org iburst
pool 0.asia.pool.ntp.org iburst

ntp service 路徑位置
$ sudo nano /lib/systemd/system/ntp.service
標案內容
[Unit]
Description=Network Time Service
Documentation=man:ntpd(8)
After=network.target
Conflicts=systemd-timesyncd.service

[Service]
Type=forking
# Debian uses a shell wrapper to process /etc/default/ntp
# and select DHCP-provided NTP servers if available
ExecStart=/usr/lib/ntp/ntp-systemd-wrapper
PrivateTmp=true

[Install]
WantedBy=multi-user.target






留言

這個網誌中的熱門文章

電話線四芯或二芯(4C或2C)的差別

開機自動執行 Google Chrome App on Mac OS X