语境:
Centos 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