linux服务器时间校对

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.13)

receive(114.80.81.13)

transmit(114.80.81.13)

receive(114.80.81.13)

transmit(114.80.81.13)

receive(114.80.81.13)

transmit(114.80.81.13)

transmit(114.80.81.12)

receive(114.80.81.12)

transmit(114.80.81.12)

receive(114.80.81.12)

transmit(114.80.81.12)

receive(114.80.81.12)

transmit(114.80.81.12)

receive(114.80.81.12)

transmit(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

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

refid [114.80.81.12], delay 0.07466, dispersion 0.00002

transmitted 4, in filter 4

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 

         0.00000 0.00000 0.00000 0.00000 

filter offset: 0.389573 0.389545 0.389564 0.389362

         0.000000 0.000000 0.000000 0.000000

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

 

Linux提示no crontab for root的解决办法  

 

解决办法:

可以自己创建一个配置文件来添加上去

    1. #vi hello-conf

    1-59 * * * * ntpdate pool.ntp.org

    2. #crontab -u root hello-conf

    3. #crontab -l    应该就可以列出任务列表了。

    4. #crontab -e    现在就可以用这个命令来编辑配置文件了

 

 

四、查看计划任务是否执行

[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)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章