強制計時時間檢查

強制計時時間檢查

情境:

  • 森托斯7.0

  • chronyc (chrony) 版本 3.1 (+READLINE +IPV6 +DEBUG)


問題

我想要找到一種方法強制 chronyd 立即更改硬體時鐘無需等待。

該程式chronyd目前正在我的機器上運行:

[root@localhost ~]# ps -ef | grep chronyd
   chrony     599     1  0 21:59 ?        00:00:00 /usr/sbin/chronyd
   root      6710  4779  0 22:31 pts/0    00:00:00 grep --color=auto chron

chronyd實際上在文件中是這樣配置的/etc/chrony.conf

   # 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

   # Enable kernel synchronization of the real-time clock (RTC).
   rtcsync

   # Enable hardware timestamping on all interfaces that support it.
   hwtimestamp *

   # Increase the minimum number of selectable sources required to adjust
   # the system clock.
   #minsources 2

   # Allow NTP client access from local network.
   allow 192.168.0.0/16

   # Ignore stratum in source selection.
   stratumweight 0

   # Specify directory for log files.
   logdir /var/log/chrony

   # Select which information is logged.
   #log measurements statistics tracking
   pool chronos.univ-brest.fr

機器目前詢問的 NTP 主機是chronos.univ-brest.fr並且機器能夠 ping 通它:

 [root@localhost ~]# ping chronos.univ-brest.fr
   PING chronos.univ-brest.fr (195.83.247.18) 56(84) bytes of data.
   64 bytes from chronos.univ-brest.fr (195.83.247.18): icmp_seq=1 ttl=239 time=38.3 ms
   64 bytes from chronos.univ-brest.fr (195.83.247.18): icmp_seq=2 ttl=239 time=38.7 ms

我發現的唯一類似的帖子並不能解決我的問題https://stackoverflow.com/questions/49730407/how-to-resynchronize-with-chrony


機器上的當前日期如下:

[root@localhost ~]# date
   jeu. févr.  2 22:40:21 CET 1978

我想找到一種方法來強制chronyd將硬體時鐘立即更改為 NTP 主機給出的日期。

答案1

如果 chronyd 尚未運行,則類似於「ntpdate pool.ntp.org」的命令可能是(自版本 1.30 起):

chronyd -q 'server pool.ntp.org iburst'

如果它已經在運行並且配置了一些伺服器,則等效內容是:

chronyc -a 'burst 4/4'

如果您希望 chronyd 也步進時脈而不是旋轉(如果有較大的偏移量且 chrony.conf 不包含無限制的 makestep 指令),您還需要等到進行新的測量,然後告訴 chronyd 進行步:

sleep 10
chronyc -a makestep

相關內容