Linux关于时间同步命令

来源:互联网 发布:python string转list 编辑:程序博客网 时间:2024/06/05 04:12
Linux时间同步设置时区cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime联网情况:ntpdate us.pool.ntp.org修改时间date -s 11:21:00查看NTP状态service ntpd statusyum install -y ntpdchkconfig ntpd on#查看时区date -R#同步网络时间ntpdate 1.centos.pool.ntp.org配置ntp服务端:vi /etc/ntp.confrestrict 172.16.0.0 mask 255.255.255.0 nomodify notrap#使用本地时钟server  127.127.1.0fudge   127.127.1.0    stratum 10保存退出#开启防火墙udp 123端口iptables -I INPUT -p udp --dport 123 -j ACCEPTservice iptables save#在启动ntpd服务之前,先使用ntpdate手动同步下时间,免得本机与外部时间服务器时间差距太大,让ntpd不能正常同步。ntpdate 0.centos.pool.ntp.org #启动ntpd服务service ntpd start#其他机器机器发送同步请求ntpdate 172.16.0.11开机启动/etc/rc.d/rc.local

一般先 sudo date -s "2017-12-23 14:20:33"

     sudo service ntpd start 

其他节点同步这个节点

   sudo ntpdate 192.168.33.22  就会同步时间