rdateでサーバの時計あわせ

あるちゅう

2011年07月07日 06:36

外部(インターネット)に接続していない、ローカル空間のサーバ間で時刻を同期せたい場合はrdateコマンドが便利。

時刻合わせをしたいサーバをhost2(192.168.0.2)、ネタ元(こいつ合わせる!!)をhost1(192.168.0.1)とする。

以下、RHELの場合

[hoge@host2 ~]$ rdate 192.168.0.1
192.168.0.1から日時を取得しを表示

[root@host2 ~]# rdate -s 192.168.0.1
192.168.0.1から日時を取得しセット(特権ユーザーじゃないと駄目)

rdate: couldn't connect to host 192.168.0.1: Connection refused

って表示されたら、接続先(192.168.0.1)のtimeサービスが無効状態のはず。


接続先(192.168.0.1)にloginしtimeサービスを有効にする。

[root@host1 ~]# /sbin/chkconfig time-dgram on
[root@host1 ~]# /sbin/chkconfig time-stream on
timeサービスを有効化

[root@host1 ~]# /sbin/service xinetd restart
xinetdを再起動

備忘録



関連記事