Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

chronyc

Talk to the chrony NTP daemon: show time sources, sync state and statistics, or make the clock step.

Level
RHCSA exam
Group
Time
Needs root
For changes
Package
chrony

What it does

chronyd syncs the clock with the servers in /etc/chrony.conf. chronyc sources lists them (the one with ^* is used); chronyc tracking shows how far the clock is from the reference. Some commands (like makestep) need root.

How to write it

chronyc [OPTION]... [COMMAND]...

Main parts

sources [-v]
Time sources and their state (-v = with a legend).
sourcestats [-v]
Drift and offset statistics per source.
tracking
Sync state of the system clock.
makestep
Correct the clock at once (step).
activity
Number of online/offline sources.
clients
NTP clients of this server.
ntpdata [ADDR]
Details of the last NTP packets.
online / offline
Mark sources online or offline.
burst N/M
Send quick measurements.
add server NAME / delete ADDR
Change sources at run time.
reload sources
Reload sources from sourcedir files.
serverstats
Statistics of the NTP server part.
waitsync [N [MAX [MAXSKEW [INTERVAL]]]]
Wait until synchronized (scripts).
rtcdata
RTC information.

Options 13

Most used

-n
Do not resolve addresses to names.
-c
CSV output.
-4, -6
Use IPv4 or IPv6 only.
-N
Show the original source names.
-a
Authenticate (old option).
-e
End each answer with a dot line.
-d
Debug.
-m
Allow several commands on the command line.
-h HOST
Connect to chronyd on another host.
-p PORT
Use another port.
-f FILE
Config file (ignored, for compatibility).
-v, --version
Show the version.
--help
Show help.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Which sources?

    chronyc sources
    MS Name/IP address         Stratum Poll Reach LastRx Last sample
    ===============================================================================
    ^* server1                       3   6   377    34   +112us[ +140us] +/-   18ms

    ^* = selected source; Reach 377 = the last 8 polls worked.

  2. 2With a legend

    chronyc sources -v

    Explains every column.

  3. 3Is the clock synced?

    chronyc tracking
    Reference ID    : C0A87A0A (server1)
    Stratum         : 4
    System time     : 0.000012 seconds fast of NTP time
    Leap status     : Normal

    Leap status Normal = synchronized.

  4. 4Correct a big offset now

    chronyc makestep
    200 OK

    Normally chrony slews slowly; makestep jumps.

  5. 5Wait in a script until synced

    chronyc waitsync 30 0.1

    Up to 30 tries until the offset is under 0.1 s.

  6. 6NTP clients of a time server

    chronyc clients

    Which hosts sync from this server.

  7. 7Statistics

    chronyc sourcestats -v

    Frequency and offset of each source.

  8. 8Add a server at run time

    chronyc add server 192.168.122.1 iburst

    Not saved; put it in chrony.conf too.

  9. 9Activity

    chronyc activity
    200 OK
    1 sources online

    Count of reachable sources.

  10. 10Check a remote chronyd

    chronyc -h server1 tracking

    Needs cmdallow on the remote side.

Files

/etc/chrony.conf
Servers, pools, allow lines.
/var/lib/chrony/drift
Clock drift data.

Exit codes

0 :: Done. 1 :: Error.