pve服务器内网同步时钟
1. 思路
利用 systemd-timesyncd 服务实现
2. 实现
修改配置文件,重启服务
nano /etc/systemd/timesyncd.conf
[Time]
NTP=10.1.89.1
重启服务
systemctl restart systemd-timesyncd
3. 检查
3.1 文件方式
/var/lib/systemd/timesync/clock
此文件的修改时间表示上次成功同步的时间戳。 如果无法同步,则至少表示 systemd 的 编译时间。
/run/systemd/timesync/synchronized
每次同步成功时都会 touch 该文件,以帮助 systemd-time-wait-sync 及其他程序 检测同步事件。
3.2 服务日志方式
systemctl status systemd-timesyncd
>>
systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/etc/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/systemd-timesyncd.service.d
└─disable-with-time-daemon.conf
Active: active (running) since Tue 2021-03-01 16:43:48 CST; 16s ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 1415788 (systemd-timesyn)
Status: "Synchronized to time server for the first time 10.1.89.1:123 (10.1.89.1)."
Tasks: 2 (limit: 7372)
Memory: 1.6M
CGroup: /system.slice/systemd-timesyncd.service
└─1415788 /lib/systemd/systemd-timesyncd
Mar 01 16:43:48 pve08 systemd[1]: Starting Network Time Synchronization...
Mar 01 16:43:48 pve08 systemd[1]: Started Network Time Synchronization.
Mar 01 16:43:45 pve08 systemd-timesyncd[1415788]: Synchronized to time server for the first time 10.1.89.1:123 (10.1.89.1
引用/延伸:
http://manpages.ubuntu.com/manpages/bionic/zh_TW/man1/timedatectl.1.html
http://www.jinbuguo.com/systemd/systemd-timesyncd.service.html
http://www.jinbuguo.com/systemd/timesyncd.conf.html#