天天看點

linux伺服器時間校對

一、檢視伺服器時間漂移

[root@localhost ~]# ntpdate -d pool.ntp.org

3 jun 12:23:02 ntpdate[23209]: ntpdate [email protected] thu jan 22 02:50:41 utc 2009 (1)

looking for host pool.ntp.org and service ntp

host found : 114.80.81.13

transmit(114.80.81.13)

receive(114.80.81.13)

transmit(114.80.81.12)

receive(114.80.81.12)

server 114.80.81.13, port 123

stratum 2, precision -19, leap 00, trust 000

refid [114.80.81.13], delay 0.07500, dispersion 0.00000

transmitted 4, in filter 4

reference time:    cfb1abe6.c1705427 thu, jun 3 2010 12:19:50.755

originate timestamp: cfb1aca6.e02c965f thu, jun 3 2010 12:23:02.875

transmit timestamp: cfb1aca6.72dc3bd5 thu, jun 3 2010 12:23:02.448

filter delay: 0.07510 0.07500 0.07520 0.07578 

         0.00000 0.00000 0.00000 0.00000 

filter offset: 0.401860 0.401864 0.401836 0.401890

         0.000000 0.000000 0.000000 0.000000

delay 0.07500, dispersion 0.00000

offset 0.401864

server 114.80.81.12, port 123

refid [114.80.81.12], delay 0.07466, dispersion 0.00002

reference time:    cfb1a5be.cab58f10 thu, jun 3 2010 11:53:34.791

originate timestamp: cfb1aca7.0fc8e87f thu, jun 3 2010 12:23:03.061

transmit timestamp: cfb1aca6.a5c93ea2 thu, jun 3 2010 12:23:02.647

filter delay: 0.07474 0.07477 0.07466 0.07497 

filter offset: 0.389573 0.389545 0.389564 0.389362

delay 0.07466, dispersion 0.00002

offset 0.389564

3 jun 12:23:02 ntpdate[23209]: adjust time server 114.80.81.12 offset 0.389564 sec

二、伺服器時間同步

[root@localhost ~]# ntpdate pool.ntp.org

3 jun 12:24:52 ntpdate[23216]: adjust time server 114.80.81.12 offset 0.389726 sec

三、将時間同步寫入到計劃任務

[root@localhost ~]# crontab -l

#time synchronization

0 */2 * * * "ntpdate pool.ntp.org">/dev/null 2>&1

四、檢視計劃任務是否執行

[root@localhost ~]# grep ntpdate /var/log/cron

如果出現下面資訊,且每2小時執行一次,說明配置正确

jun 1 18:00:01 localhost crond[4729]: (root) cmd ("ntpdate pool.ntp.org">/dev/null 2>&1)

jun 1 20:00:01 localhost crond[5959]: (root) cmd ("ntpdate pool.ntp.org">/dev/null 2>&1)

繼續閱讀