实验环境:
服务端IP地址192.168.10.4
客户端IP地址172.16.100.202
chrony为全网提供时间同步服务器
apt install chrony -y #安装chrony服务
vim /etc/chrony/chrony.conf
注释掉第三行
3 #pool 2.debian.pool.ntp.org iburst
4 server 192.168.10.4 iburst #服务器IP地址
5 allow 0.0.0.0/0 #允许连接的IP地址
6 local stratum 10 #连接不到ntp服务器时,用本地时间同步时间

timedatectl set-ntp yes #开启ntp同步
systemctl restart chrony #重启服务
客户端配置:
apt install chrony ntpdate -y #安装chrony和ntpdate
修改配置文件
vim /etc/chrony/chrony.conf
注释掉第三行
3 #pool 2.debian.pool.ntp.org iburst
29 server 192.168.10.4 iburst #添加服务器IP地址

?开启ntp同步
timedatectl set-ntp yes #开启ntp同步
systemctl restart chrony #重启chrony服务
定时计划在服务端上面做
每隔一分钟同步一次
vim /etc/crontab
*/1 * * * * root /usr/sbin/ntpdate 192.168.10.4

测试
chrony服务器查看连接的客户端
chronyc clients

?客户端查看连接的chrony服务器
chronyc sources -v

?服务端查看时间

?客户端查看时间

?
|