リモートサーバークエリ

リモートサーバークエリ

man ntpdateCentOS 7.2サーバーの場合:

   Disclaimer:  The functionality of this program is now available in the
   ntpd program. See the -q command line option in  the  ntpd  -  Network
   Time  Protocol (NTP) daemon page. After a suitable period of mourning,
   the ntpdate program is to be retired from this distribution

からman ntpd

   -q      Exit the ntpd just after the first time the clock is set. This
           behavior  mimics  that  of the ntpdate program, which is to be
           retired. The -g and -x options can be used with  this  option.
           Note: The kernel time discipline is disabled with this option.

これはコマンドの一般的な機能を模倣しますntpdate。しかし、ntpdate独自のフラグもあります。-q

   -q      Query only - don't set the clock.

マニュアルページにはntpdこれを行う方法はありません。

ntpdate最終的に段階的に廃止される予定なので、ntpdate -q現在提供されている機能を得るために好む将来の互換方法は何ですか?

ベストアンサー1

リモートサーバークエリ

リモートNTPサーバーに照会するには、次のようにします。

# sntp 0.debian.pool.ntp.org
sntp [email protected] Sun Feb 25 21:22:25 UTC 2018 (1)
2018-10-03 04:34:02.687911 (+0400) -0.002893 +/- 0.063203 0.debian.pool.ntp.org 186.118.171.89 s3 no-leap

ntpd時間設定

サーバー時間を設定するには:

最新バージョンのntpdを使用してください。

# ntpd --version
ntpd [email protected] Sun Feb 25 21:22:55 UTC 2018 (1)

オプションは-qマニュアルに次のように表示されます。

-q初めて時計を設定した直後にntpdを終了します。この動作は破棄されるntpdateプログラムと似ています。 -gオプションと-xオプションをこのオプションと一緒に使用できます。注:カーネルタイムルールを無効にするには、このオプションを使用します。

したがって、ntpデーモンを停止した後(service ntpd stopまたはsystemctl stop ntpシステムに応じて)、次のコマンドを使用してください。

# ntpd -gq

-gqはntpデーモンにオフセット(g)に関係なく時間を変更し、時間(q)を設定してすぐに終了するように指示します。

その後、再起動してntpd正しく機能していることを確認してください。

# ntpq -pn

おすすめ記事