Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1053499
  • 博文数量: 155
  • 博客积分: 5339
  • 博客等级: 大校
  • 技术积分: 1436
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-10 21:41
文章分类

全部博文(155)

文章存档

2016年(3)

2015年(7)

2014年(3)

2013年(1)

2012年(8)

2011年(5)

2010年(1)

2009年(5)

2008年(4)

2007年(26)

2006年(46)

2005年(46)

分类: LINUX

2015-03-05 16:50:10

linux系统有两个时钟:一个是由主板电池驱动的“Real Time Clock”也叫做RTC或者叫CMOS时钟,硬件时钟;一个时间是 “System clock”也叫内核时钟或者软件时钟
这两个时钟通常会有一些误差,长时间可以导致这两个时钟偏离的比较多。
我们可以使用
adjtimex工具查看误差并进行调整。

使用adjtimex --c 命令查看误差值
这是一个误差较小的情况,每10秒误差在毫秒级别以下

点击(此处)折叠或打开

  1. --- current --- -- suggested --
  2. cmos time system-cmos 2nd diff tick freq tick freq
  3. -1730257880 3155800985.365904 3155800985.365904 10000 0
  4. -1730257870 3155800985.365680 -0.000225 10000 0
  5. -1730257860 3155800985.365458 -0.000222 10000 0 10000 1453125
  6. -1730257850 3155800985.365235 -0.000223 10000 0 10000 1462500
  7. -1730257840 3155800985.365017 -0.000218 10000 0 10000 1428125
  8. -1730257830 3155800985.364792 -0.000225 10000 0 10000 1471875
  9. -1730257820 3155800985.364572 -0.000221 10000 0 10000 1446875
  10. -1730257810 3155800985.364353 -0.000219 10000 0 10000 1434375

使用命令调整:adjtimex --frequency 1446875,调整后相对误差已经非常小

点击(此处)折叠或打开

  1. --- current --- -- suggested --
  2. cmos time system-cmos 2nd diff tick freq tick freq
  3. -1730257412 3155800985.355584 3155800985.355584 10000 1446875
  4. -1730257402 3155800985.355587 0.000002 10000 1446875
  5. -1730257392 3155800985.355592 0.000006 10000 1446875 10000 1409375
  6. -1730257382 3155800985.355597 0.000004 10000 1446875 10000 1418750
  7. -1730257372 3155800985.355603 0.000006 10000 1446875 10000 1406250
  8. -1730257362 3155800985.355610 0.000007 10000 1446875 10000 1400000
  9. -1730257352 3155800985.355613 0.000003 10000 1446875 10000 1425000
  10. -1730257342 3155800985.355621 0.000008 10000 1446875 10000 1393750
(列表的最后两列为根据误差推荐的tick值和frequency值,不想计算,可以直接使用推荐值)

另个误差数据表,tick值需要调整

点击(此处)折叠或打开

  1. --- current --- -- suggested --
  2. cmos time system-cmos 2nd diff tick freq tick freq
  3. -1730245151 3155787261.925895 3155787261.925895 10000 0
  4. -1730245141 3155787261.924479 -0.001416 10000 0
  5. -1730245131 3155787261.923068 -0.001411 10000 0 10001 2696400
  6. -1730245121 3155787261.921656 -0.001411 10000 0 10001 2696400
  7. -1730245111 3155787261.920248 -0.001409 10000 0 10001 2677650
  8. -1730245101 3155787261.918836 -0.001412 10000 0 10001 2699525
  9. -1730245091 3155787261.917424 -0.001411 10000 0 10001 2696400
  10. -1730245081 3155787261.916017 -0.001408 10000 0 10001 2671400
使用命令adjtimex --tick 10001调整:

点击(此处)折叠或打开

  1. --- current --- -- suggested --
  2. cmos time system-cmos 2nd diff tick freq tick freq
  3. -1730245015 3155787261.907060 3155787261.907060 10001 0
  4. -1730245005 3155787261.906636 -0.000424 10001 0
  5. -1730244995 3155787261.906224 -0.000412 10001 0 10001 2696875
  6. -1730244985 3155787261.905815 -0.000410 10001 0 10001 2684375
  7. -1730244975 3155787261.905405 -0.000410 10001 0 10001 2684375
  8. -1730244965 3155787261.904994 -0.000412 10001 0 10001 2696875
  9. -1730244955 3155787261.904582 -0.000412 10001 0 10001 2696875
  10. -1730244945 3155787261.904171 -0.000411 10001 0 10001 2690625
使用adjtimex --frequency 2690625调整:

点击(此处)折叠或打开

  1. --- current --- -- suggested --
  2. cmos time system-cmos 2nd diff tick freq tick freq
  3. -1730243759 3155787261.855667 3155787261.855667 10001 2690625
  4. -1730243749 3155787261.855659 -0.000008 10001 2690625
  5. -1730243739 3155787261.855659 -0.000000 10001 2690625 10001 2693750
  6. -1730243729 3155787261.855658 -0.000001 10001 2690625 10001 2696875
  7. -1730243719 3155787261.855659 0.000000 10001 2690625 10001 2687500
  8. -1730243709 3155787261.855658 -0.000000 10001 2690625 10001 2693750
  9. -1730243699 3155787261.855660 0.000002 10001 2690625 10001 2675000
  10. -1730243689 3155787261.855661 0.000000 10001 2690625 10001 2687500

需要注意的是虚拟机调整无效,调整之前的值:

点击(此处)折叠或打开

  1. --- current --- -- suggested --
  2. cmos time system-cmos 2nd diff tick freq tick freq
  3. -1730254303 3155796902.540702 3155796902.540702 10000 0
  4. -1730254294 3155796902.646370 0.105668 10000 0
  5. -1730254285 3155796902.748293 0.101923 10000 0 9898 504700
  6. -1730254276 3155796902.856725 0.108432 10000 0 9892 -2833075
  7. -1730254267 3155796902.957014 0.100289 10000 0 9900 -1893125
  8. -1730254258 3155796903.057384 0.100370 10000 0 9900 -2424375
  9. -1730254249 3155796903.157701 0.100317 10000 0 9900 -2077500
  10. -1730254240 3155796903.258016 0.100315 10000 0 9900 -2065000
使用adjtimex --tick 9900调整:

点击(此处)折叠或打开

  1. --- current --- -- suggested --
  2. cmos time system-cmos 2nd diff tick freq tick freq
  3. -1730254147 3155796902.352214 3155796902.352214 9900 0
  4. -1730254138 3155796902.453279 0.101065 9900 0
  5. -1730254129 3155796902.554006 0.100727 9900 0 9799 1791725
  6. -1730254120 3155796902.663328 0.109322 9900 0 9791 -2110725
  7. -1730254111 3155796902.764857 0.101529 9900 0 9798 3085950
  8. -1730254102 3155796902.866494 0.101637 9900 0 9798 2379700
  9. -1730254092 3155796901.968040 -0.898453 9900 0 10798 2970325
  10. -1730254083 3155796902.070302 0.102262 9900 0 9798 -1717175
误差依然存在,调整无效。

adjtimex下载地址:

实例使用参考:
http://laowafang.blog.51cto.com/251518/1118063
adjtimex使用说明:
阅读(3823) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~