2010年6月11日 星期五

NTP 校時

要檢查目前系統時間 , 請執行
date要調整系統時間 , 請執行下列指令 : date  100114302006      #10月01日14點30分2006年
其中 date 是指令 ,
後面的數字即是現在時間 , 格式為 "月日時分西元年" ,
除西元年為四位數 , 其它皆為兩位數 .


在校正前 , 我們要先確認 Linux 系統設定的 時區(time zone)是否正確 .
執行 date 指令後 , 顯示的訊息中就有列出了 , 如下
[root@fc6 shs]# date
Thu Apr 12 17:06:11 EST 2007
[root@fc6 shs]#
         
其中 EST 就是錯誤的時區 ,
Asia/Teipei 時區應該顯示為 "CST"


修正方法如下 :
[root@fc6 shs]# cp   /usr/share/zoneinfo/Asia/Taipei   /etc/localtime
cp: overwrite `/etc/localtime'? y
[root@fc6 shs]#



再次執行 date 指令 :
[root@fc6 shs]# date
Thu Apr 12 15:31:44 CST 2007
[root@fc6 shs]#





在 Linux 系統上 , 這網路校時的指令相當簡單 ,
只要可以連上 NTP Server(時間伺服器) , 下一行指令即可 .
請執行
ntpdate  time.stdtime.gov.tw


其中 time.stdtime.gov.tw 就是 國家時間與頻率標準實驗室 所提供的 "時間伺服器"
stdtime.gov.tw 提供的 NTP Service 不只一台 Server , 以下皆是 :
time.stdtime.gov.tw
clock.stdtime.gov.tw
tick.stdtime.gov.tw
tock.stdtime.gov.tw
watch.stdtime.gov.tw



執行後若看到大致如下的畫面 , 表示 "校正" 成功 .
[root@fc5 ~]# ntpdate   time.stdtime.gov.tw
16 Oct 15:20:57 ntpdate[25963]: step time server 220.130.158.52 offset 28788.622489 sec
[root@fc5 ~]#



這時這台 Linux Server 的系統時間就與 "時間伺服器" 同步過了 .
但主機板 BIOS 的時間並不會同時校正 .
可以執行
clock  -w或者是執行
hwclock  -w
來修正 BIOS 的時間 .


沒有留言:

張貼留言