LoginSignup
8
11

More than 5 years have passed since last update.

Cent OSの時計がずれた場合にntpを入れて同期する

Posted at

VagrantにSent OS (Scientific Linux) 入れたらntp入ってなかったので時計が自動で同期されなかった。結果時計が遅れ、GitHubのコミットログがカオスった。

とりあえず時間を見てみる

$ date
2015年  9月 7日 火曜日 14:16:09 JST

一応localtimeをJapanにする

$ sudo cp -p /usr/share/zoneinfo/Japan /etc/localtime

ntpをyumで入れる

$  sudo yum -y install ntp
インストール処理の設定をしています
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package ntp.x86_64 0:4.2.6p5-5.el6 will be インストール
--> 依存性の処理をしています: ntpdate = 4.2.6p5-5.el6 のパッケージ: ntp-4.2.6p5-5.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package ntpdate.x86_64 0:4.2.6p5-5.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

...

合計                                                                                                                                                                                                           69 kB/s | 670 kB     00:09
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : ntpdate-4.2.6p5-5.el6.x86_64                                                                                                                                                                                  1/2
  インストールしています  : ntp-4.2.6p5-5.el6.x86_64                                                                                                                                                                                      2/2
  Verifying               : ntp-4.2.6p5-5.el6.x86_64                                                                                                                                                                                      1/2
  Verifying               : ntpdate-4.2.6p5-5.el6.x86_64                                                                                                                                                                                  2/2

インストール:
  ntp.x86_64 0:4.2.6p5-5.el6

依存性関連をインストールしました:
  ntpdate.x86_64 0:4.2.6p5-5.el6

完了しました!

同期する

$ sudo ntpdate ntp.nict.jp
15 Sep 14:16:07 ntpdate[20504]: step time server 133.243.238.244 offset 641189.612730 sec

$ date
2015年  9月 15日 火曜日 14:16:09 JST

できた。

ntpdを走らせて勝手に同期するようにする。

$ sudo service ntpd start
Starting ntpd:                                             [  OK  ]
8
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
11