一、NTP客户端安装

1、安装ntp服务

yum install ntp ntpdate -y

2、手动同步一次

/usr/sbin/ntpdate -u 192.168.11.33

注意:192.168.11.33要改成自己的NTP服务器地址

3、修改配置文件

vim /etc/ntp.conf
#注释掉其他上游时间服务器
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
#配置上游时间服务器为本地的ntpd Server服务器
server 192.168.11.33
#配置允许上游时间服务器主动修改本机的时间
restrict 192.168.11.33 nomodify notrap noquery

4、重启ntp服务

systemctl restart ntpd

二、同步时间

1、手工同步

/usr/sbin/ntpdate -u 192.168.11.33

2、定时同步

crontab -e
*/10 * * * * /usr/sbin/ntpdate -u 192.168.11.33

 注意:上面定时任务为每十分钟同步一次

3、查看定时任务

crontab -l

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐