Commands / Services and tunnels

Services and tunnels

chronyd

Also chrony, ntp query, ntpdate, sntp, clock offset

The chrony time daemon; with -Q it asks a server once, prints how far off the clock is and exits, setting nothing.

chronyd is chrony's daemon, the program that keeps a clock right with NTP. Given config lines on the command line it reads no config file, so chronyd -Q 'server SERVER iburst' asks that one server a few quick questions, prints System clock wrong by X seconds (ignored) and exits: the offset, measured and not applied. It is the modern ntpdate -q, and it runs beside a chronyd that is already keeping the clock.

chronyd command usage

chronyd -Q 'server SERVER iburst'
chronyd -q 'server SERVER iburst'
chronyd [-d] [-x] [-f CONFIG]

Options

-Q
ask once, print the offset, set nothing, exit
-q
ask once, set the clock, exit
'server SERVER iburst'
a config line on the command line: the server to ask, with a quick first burst
-x
never touch the system clock
-d
stay in the foreground and log to the terminal

chronyd examples

chronyd -Q 'server timeServer.lab iburst'
Asks timeServer how far off this clock is, and changes nothing.
System clock wrong by 0.000026 seconds (ignored)
chronyd -Q 'pool pool.ntp.org iburst'
Asks several servers of a public pool at once and prints the combined offset.
chronyd -q 'server timeServer.lab iburst'
Steps the clock to timeServer's time once, then exits.

Pitfalls

  • A negative offset means this clock is ahead of the server's.
  • -q sets the clock; inside a container that shares the host's clock it fails, or worse, moves the host's.

Run it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Open this lab