0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

スリープを多用するPCでVirtualBox上のCentOS7の時計がズレまくる時の対策

Last updated at Posted at 2024-05-05

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 3makestep 1.0 -1に変更すれば時刻調整がstepという早い調整方法にて行われるようになる。
ただし急激な時間変動によりアプリのエラーやログの出力がバグることがあるので注意したほうが良いとのこと。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?