在 Ubuntu server 22.04 設定 NTP server 校時
使用 systemd-timesyncd,在 ubuntu server22.04 上指定特定的 NTP server 來自動校時
1. 安裝 systemd-timesyncd
apt install systemd-timesyncd
timedatectl set-ntp true
sudo systemctl start systemd-timesyncd
2. 檢查安裝
systemctl status systemd-timesyncd
結果範例
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-02-16 11:06:08 CST; 16min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 12832 (systemd-timesyn)
Status: "Idle."
Tasks: 2 (limit: 19067)
Memory: 1.2M
CPU: 52ms
CGroup: /system.slice/systemd-timesyncd.service
└─12832 /lib/systemd/systemd-timesyncd
3. 設定:編輯 /etc/systemd/timesyncd.conf
sudo vi /etc/systemd/timesyncd.conf
內容
[Time]
NTP=ntp.server.you.want
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
4. 重啟服務,套用修改
sudo systemctl restart systemd-timesyncd
5. 驗證設定
timedatectl show-timesync --all
結果範例
LinkNTPServers=
SystemNTPServers=ntp.server.you.want
FallbackNTPServers=ntp.ubuntu.com
ServerName=ntp.server.you.want
ServerAddress=ntp.server.you.want
RootDistanceMaxUSec=5s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=34min 8s
Frequency=0
留言
張貼留言