Crazy ITer

 
Motto
It is strange that all great men should have some little grain of madness mingled with whatever genius they possess。
---------Moliere

When looking up, one has no occasion for shame before heaven, and below, one has no occasion to blush before men。
---------Mencius

The mechanic, who wishes to do his work well, must first sharpen his tools
---------Confucius

Python
SQL
UML
Zope&Plone
Ajax & Script
Jabber
Linux
让你的Linux服务器的时间一直准确
2007年4月7日星期六

我们的Linux服务器在运行一段时间后时间就会多几分钟或者少几分钟,导致应用运行的时候时间总是有些出入,因为应用程序是读取系统的当前时间,怎么来保证系统时间一直准确呢?

两种方法:

一. 手工操作,命令 date -s '2006-10-19 12:00:00' 。缺点,不够精确,经常要隔段时间就手工设置,维护工作费事劳心。

二. 自动设置

首先应该了解什么是标准时间,谁来提供标准时间,在国内我们以中科院的国家授时中心的标准时间服务器作为标准,国家授时中心的服务器地址是 210.72.145.44 。网址: http://www.ntsc.ac.cn

接下来我们利用linux的时间同步程序来对校正系统时间,使用root用户执行

> ntpdate 210.72.145.44

执行结果

18 Oct 22:38:33 ntpdate[8825]: step time server 210.72.145.44 offset -43246.688902 sec

这时候再执行date命令查看当前的日期就保持跟标准时间服务器之间的同步了。

但是有一点需要注意的是,如果你发现执行了同步时间命令后时间反倒尔不对了,那么请检查你的系统时区设置是否正确。

最后我们最好是每周对系统的时间进行一次校正,你可以将同步的命令放入crontab中定期每周执行一次。

Windows服务器的设置参考: http://www.dlog.cn/html/diary/showlog.vm?sid=2&log_id=4004

作者:刘冬

posted by William @ 07:16  
0 Comments:
发表评论
<< Home
 
About Me

Name: William
Home: Pudong, Shanghai, China
About Me: Here is a collection of my program notes.I'd like to put all my notes and learning together.Welcome anybody to help me to perfect it.
See my complete profile
Previous Post
Archives
Links
© 2005 Crazy ITer Template by Isnaini Dot Com