chronyを使用する方法。
まずはtimedatectl
コマンドでNTP syncronizedのyes/noを確認する。
$ timedatectl
Local time: 月 2024-02-12 18:16:48 JST
Universal time: 月 2024-02-12 09:16:48 UTC
RTC time: 月 2024-02-12 09:16:48
Time zone: Asia/Tokyo (JST, +0900)
NTP enabled: yes
NTP synchronized: no ←コイツ!!
RTC in local TZ: no
DST active: n/a
noになっているのでchronyでyesにする必要がある。
systemctl start chronyd
とコマンド入力するとパスワードを求められるので入力する。
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
再起動しないとyesにならないのでsystemctl restart chronyd
と入力する。再度パスを求められる。
chronyを再起動したらtimedatectl
で時刻とNTP synchronizedのyesを確認して
お終いと思ったが時刻調整の方式がとても遅い方式なのでうんたらかんたら…。
というわけで/etc/chrony.conf
をviで開いて編集する必要がある。
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3 ←コレ
(略)
makestep 1.0 3
をmakestep 1.0 -1
に変更すれば時刻調整がstepという早い調整方法にて行われるようになる。
ただし急激な時間変動によりアプリのエラーやログの出力がバグることがあるので注意したほうが良いとのこと。