Skip to Content

The Essential Guide to Using Chrony for NTP on Linux

When I first started working with Linux servers, managing time synchronization seemed like a daunting task.

My team had always relied on the traditional ntpd service for Network Time Protocol (NTP), and it worked well enough.

But when Red Hat Enterprise Linux (RHEL) 8 came around and the focus shifted to chronyd from the Chrony suite, I knew it was time to dive into something new.

My initial encounter with Chrony was both intriguing and challenging. The promise of improved accuracy, especially in virtualized environments and with intermittent network connections, caught my attention.

I decided to take the plunge and migrate our timekeeping services from ntpd to Chrony.

This article explores how to configure and manage time synchronization using Chrony, highlighting its benefits and how to migrate from older NTP methods.

Understanding the Chrony Suite

Chrony is a modern NTP implementation designed for accuracy and flexibility, especially in challenging conditions such as intermittent connections or fluctuating temperatures. It consists of two main components:

  • chronyd: The daemon that runs in user space to synchronize system time.
  • chronyc: A command-line utility used to monitor and control chronyd.

Chrony can:

  • Sync the system clock with NTP servers.
  • Use reference clocks, such as GPS receivers.
  • Accept manual time inputs.
  • Act as an NTPv4 server or peer to provide time services to other network computers.

Chrony provides excellent accuracy, with typical synchronization within milliseconds over the Internet and microseconds on a local network. For even finer precision, hardware timestamping or reference clocks can achieve sub-microsecond accuracy.

Configuring Chrony with chronyc

To manage chronyd, you use the chronyc command-line utility. Here’s how to use it:

  • Interactive Mode: Start chronyc as root:
    # chronyc

    This opens an interactive prompt where you can enter commands. For a list of available commands, type help.

  • Non-Interactive Mode: Execute commands directly:
    chronyc command

    Remember that changes made via chronyc are not permanent; to make persistent changes, you should edit the /etc/chrony.conf file.

Migrating from ntpd to chronyd

With the introduction of RHEL 8, ntpd is no longer supported, and chronyd is the default.

Migrating from ntpd to chronyd involves mapping configurations from ntpd to chronyd. Here’s a quick reference:

ntpd Name chronyd Name
/etc/ntp.conf /etc/chrony.conf
/etc/ntp/keys /etc/chrony.keys
ntpd chronyd
ntpq chronyc
ntpd.service chronyd.service
ntpdate chronyd -q

The ntpdate and sntp utilities, previously part of the NTP distribution, can be replaced by chronyd.

You can use the -q or -t options to specify configurations directly on the command line, bypassing the need to read from /etc/chrony.conf.

For instance, instead of using ntpdate ntp.example.com, you can start chronyd with:

# chronyd -q 'server ntp.example.com iburst'
2018-05-18T12:37:43Z chronyd version 3.3 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
2018-05-18T12:37:43Z Initial frequency -2.630 ppm
2018-05-18T12:37:48Z System clock wrong by 0.003159 seconds (step)
2018-05-18T12:37:48Z chronyd exiting

Installing and Managing Chrony

Chrony is usually pre-installed on RHEL systems. If it’s not, you can install it with:

# yum install chrony

To manage the chronyd service, use these systemd commands:

  • Start Chronyd:
    # systemctl start chronyd
  • Enable Chronyd to Start on Boot:
    # systemctl enable chronyd
  • Stop Chronyd:
    # systemctl stop chronyd
  • Disable Chronyd from Starting on Boot:
    # systemctl disable chronyd

Verifying Chrony Synchronization

To check if chronyd is properly synchronized, use the following chronyc commands:

  • Tracking:
    $ chronyc tracking
    Reference ID    : CB00710F (ntp-server.example.net)
    Stratum         : 3
    Ref time (UTC)  : Fri Jan 27 09:49:17 2017
    System time     :  0.000006523 seconds slow of NTP time
    Last offset     : -0.000006747 seconds
    RMS offset      : 0.000035822 seconds
    Frequency       : 3.225 ppm slow
    Residual freq   : 0.000 ppm
    Skew            : 0.129 ppm
    Root delay      : 0.013639022 seconds
    Root dispersion : 0.001100737 seconds
    Update interval : 64.2 seconds
    Leap status     : Normal
    
  • Sources:
    $ chronyc sources
    	210 Number of sources = 3
    MS Name/IP address         Stratum Poll Reach LastRx Last sample
    ===============================================================================
    #* GPS0                          0   4   377    11   -479ns[ -621ns] /-  134ns
    ^? a.b.c                         2   6   377    23   -923us[ -924us] +/-   43ms
    ^ d.e.f                         1   6   377    21  -2629us[-2619us] +/-   86ms
    
  • Source Statistics:
    $ chronyc sourcestats
    210 Number of sources = 1
    Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
    ===============================================================================
    abc.def.ghi                11   5   46m     -0.001      0.045      1us    25us
    

 

In conclusion, embracing Chrony for NTP configuration has been a rewarding experience. It’s a testament to how adopting newer technologies can lead to significant improvements in system performance and reliability.

If you’re still using ntp, I highly recommend giving Chrony a try—your timekeeping will thank you.