天天看點

linux--ntp同步時間

             linux ntp 同步時間

弑神linux機器時間同步方法:

(1) #/etc/init.d/ntpd stop先關閉本機的ntp服務

(2) #vim /etc/crontab 添加計劃任務

0 3 ** *root ntpdate 219.238.221.31

(3) #vim /etc/sysconfig/ntpd#執行系統時間與硬體時間同步

sync_hwclock=yes

(4) #clock -w将系統時間寫入硬體

(5) #ntpq -p檢視ntp服務狀态資訊

synchronised to ntp server(115.182.1.207) at stratum 3

time correct to within 112 ms

polling server every 1024 s

(6) #netstat -tunl|grep 123檢視ntp端口

udp00 192.168.60.59:1230.0.0.0:*

udp00 118.26.227.59:1230.0.0.0:*

udp00 127.0.0.1:1230.0.0.0:*

udp00 0.0.0.0:1230.0.0.0:*

udp00 ::1:123:::*

udp00 :::123:::*

(7) #vim /etc/ntp.conf

restrict 127.0.0.1

restrict -6 ::1

restrict default kod nomodify notrapnopeer noquery

restrict -6 default kod nomodifynotrap nopeer noquery

driftfile /var/lib/ntp/drift

server ntp1.gyyx.cn

server ntp2.gyyx.cn

server 219.238.221.31 prefer

繼續閱讀