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.
burstN/M- Send quick measurements.
addserverNAME/deleteADDR- Change sources at run time.
reloadsources- 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
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
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.
2With a legend
chronyc sources -vExplains every column.
3Is the clock synced?
chronyc tracking Reference ID : C0A87A0A (server1) Stratum : 4 System time : 0.000012 seconds fast of NTP time Leap status : NormalLeap status Normal = synchronized.
4Correct a big offset now
chronyc makestep 200 OKNormally chrony slews slowly; makestep jumps.
5Wait in a script until synced
chronyc waitsync 30 0.1Up to 30 tries until the offset is under 0.1 s.
6NTP clients of a time server
chronyc clientsWhich hosts sync from this server.
7Statistics
chronyc sourcestats -vFrequency and offset of each source.
8Add a server at run time
chronyc add server 192.168.122.1 iburstNot saved; put it in chrony.conf too.
9Activity
chronyc activity 200 OK 1 sources onlineCount of reachable sources.
10Check a remote chronyd
chronyc -h server1 trackingNeeds
cmdallowon the remote side.
Nothing matches this filter.
Files
/etc/chrony.conf- Servers, pools, allow lines.
/var/lib/chrony/drift- Clock drift data.
Exit codes
0 :: Done. 1 :: Error.