http://www.ntp.org/downloads.html
より、ソースをダウンロードして展開。
展開したディレクトリに移動して、
# ./cofigure # make # make install
で、インストール完了。
次にconfファイルを作成。
# mkdir /etc/ntp # vi /etc/ntp.conf server hoge.timeserver → 適当なタイムサーバのIPアドレスかサーバ名を指定 driftfile /etc/ntp/drift → /etc/ntp というディレクトリをあらかじめ作成のこと logfile /var/log/ntpd → ログファイルを指定します。
次に起動スクリプトを作成
-----/etc/rc.d/init.d/ntpd ファイルの中身 ----- #!/bin/sh # # ntpd This shell script takes care of starting and stopping # ntpd (NTPv4 daemon). # # chkconfig: - 26 74 # description: ntpd is the NTPv4 daemon. # Source function library. . /etc/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x /usr/local/bin/ntpd -a -f /etc/ntp.conf ] || exit 0 RETVAL=0 prog="ntpd" start() { # Adjust time to make life easy for ntpd if [ -f /etc/ntp/step-tickers ]; then echo -n $"Synchronizing with time server: " /usr/local/bin/ntpdate -s -b -p 8 -u `/bin/sed -e 's/#.*//' /etc/ntp/step-tickers` success echo fi # Start daemons. echo -n $"Starting $prog: " daemon /usr/local/bin/ntpd RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd return $RETVAL } stop() { # Stop daemons. echo -n $"Shutting down $prog: " killproc ntpd RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ntpd return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ntpd RETVAL=$? ;; restart|reload) stop start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/ntpd ]; then stop start RETVAL=$? fi ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 1 esac exit $RETVAL
起動スクリプトを有効化
# chmod +x /etc/rc.d/init.d/ntpd # chkconfig --add ntpd → サービスに追加します # chkconfig ntpd on # chkconfig --list ntpd → 確認します。 ntpd 0:オフ 1:オフ 2:オフ 3:オン 4:オン 5:オン 6:オフ
サービスの起動
# service ntpd start
動作確認
$ ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *clock.nc.fukuok .GPS. 1 u 178 1024 377 140.510 -56.276 83.192
サーバ名の前に*がついてたら同期完了。