天天看點

linux下設定時間同步伺服器(NTP)

linux下設定時間同步伺服器

兩種辦法

第一,可以從時間伺服器time.nist.gov同步。

在crontab中加入:

00 0 1 * * root rdate -s time.nist.gov

第二,自己建個時間伺服器

1). # rpm -ivh ntp-4.2.2p1-7.el5.i386.rpm

2). # vi /etc/ntp.conf

注釋一行

restrict default ignore

加入一行

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

3). # vi /etc/ntp/step-tickers

pool.ntp.org

這樣每次ntpd啟動時,會自動連接配接該國際标準時間伺服器;

4). # service ntpd start

5). # netstat -an |grep 123

確定該端口以udp方式開放

時間用戶端配置(192.168.1.2)

1). # ntpdate -s 192.168.1.1

應該顯示同步成功

2). # crond -e

加入

0-59/10 * * * * /usr/sbin/ntpdate 192.168.1.1

表示每隔10分鐘同步一次時間

    本文轉自vcdog 51CTO部落格,原文連結:http://blog.51cto.com/255361/837813,如需轉載請自行聯系原作者

繼續閱讀