Chinaunix首页 | 论坛 | 博客
  • 博客访问: 112790
  • 博文数量: 27
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 360
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-07 00:14
文章分类

全部博文(27)

文章存档

2015年(1)

2014年(20)

2013年(6)

我的朋友

分类: LINUX

2014-01-16 23:00:50

linux服务器时间校对
 
 

一、查看服务器时间漂移

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

3 Jun 12:23:02 ntpdate[23209]: ntpdate 4.2.2p1@1.1570-o 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 && hwclock -w 

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)
阅读(884) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~