Nfernandez
Nfernandez

Reputation: 736

How to do "one shot" time sync using chrony?

I am looking for an equivalent of 'ntpdate IPaddress' command in the chrony suite to force chronyd to synchronize time right now.

Upvotes: 48

Views: 169456

Answers (4)

swampf0etus
swampf0etus

Reputation: 411

If you're getting:

Could not read keyfile or commandkey in file /etc/chrony.conf

when running:

sudo chronyc -a makestep

Then make sure you have the following line in /etc/chrony.conf:

keyfile /etc/chrony.keys

And make sure you have a password for key 0 in /etc/chrony.keys:

0 SHA1 HEX:9222248F87B1FDDB01716FC8F1A7B5AB13CDAC91

You can generate a SHA1 hashed password:

echo -n Th15is4Pa55w0rd! | sha1sum
9222248F87B1FDDB01716FC8F1A7B5AB13CDAC91

If that doesn't work, it may be because you have commandkey specified as something other than 0 in your /etc/chrony.conf. The default is 0, so if it's set to something else you need to align it with what's in /etc/chrony.keys.

Upvotes: 0

Nadav Aharoni
Nadav Aharoni

Reputation: 191

In my setup, for various reasons, chronyd is disabled and we want to occasionally manually sync with an NTP server.

For this type of scenario, the command in Rob Newton's answer is the one that worked (thanks!).

Note that if you are querying the ntp pool, it is advisable to use the pool command, as in:

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

See this question for additional details.

Also note that if the chronyd service is not running, the command sudo chronyc -a makestep in Richard Green's answer will not work, since it tries to communicate with the chronyd daemon.

Upvotes: 13

Robert Newton
Robert Newton

Reputation: 1611

The chrony equivalent to the ntpdate SERVER-ADDRESS command is:

    chronyd -q 'server SERVER-ADDRESS iburst'

Note that chronyd must not be already running, just as ntpd must not be running when setting the date with ntpdate.

Upvotes: 21

Richard Green
Richard Green

Reputation: 851

Try

sudo chronyc -a makestep

This will update your system clock quickly (might break some running applications), using the time sources defined in /etc/chronyd.conf.

-a is needed to avoid

501 Not authorised error

Upvotes: 75

Related Questions