9

Context:

  • Centos 7.0

  • chronyc (chrony) version 3.1 (+READLINE +IPV6 +DEBUG)


Issue

I want to find a way to force chronyd to change the hardware clock instantly without waiting.

The program chronyd is currently running on my machine :

[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 is actually configured this way in the file /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

The NTP host the machine is currently asking is chronos.univ-brest.fr and the machine is able to ping it :

 [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

The only similar post i found does not solve my problem https://stackoverflow.com/questions/49730407/how-to-resynchronize-with-chrony


The current date on the machine is the following :

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

I would like find a way to force chronyd to change the hardware clock instantly to the date given by the NTP host.

Orelsanpls
  • 193
  • 1
  • 1
  • 6

1 Answers1

18

If chronyd isn't already running, a command similar to 'ntpdate pool.ntp.org' could be (since version 1.30):

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

If it's already running and it has some servers configured, an equivalent would be:

chronyc -a 'burst 4/4'

If you want chronyd to also step the clock instead of slewing if there is a larger offset and chrony.conf doesn't include an unlimited makestep directive, you will also need to wait until the new measurements are made and then tell chronyd to make the step:

sleep 10
chronyc -a makestep
Arlion
  • 590
  • 1
  • 4
  • 17