Skip to content

How to Install and Use Chrony in Linux

Share

Reading Time: 3 minutes

How to Install and Use Chrony in Linux. Accurate timekeeping is crucial for the smooth functioning of systems, especially in distributed networks, data centers, and applications that rely on synchronization. Chrony is a versatile Network Time Protocol (NTP) implementation that offers better performance and faster synchronization compared to traditional NTP daemons. This guide will walk you through the installation, configuration, and usage of Chrony in Linux environments.

What is Chrony?

Chrony is an NTP client and server designed to synchronize the system clock with NTP servers, local reference clocks, or manual time inputs. It is particularly useful for systems that do not have a continuous network connection, as it handles intermittent synchronization effectively.

Chrony is preferred over the traditional ntpd (NTP daemon) due to its faster time synchronization, resilience to unstable networks, and enhanced security features.

Key Features of Chrony

  • Fast Synchronization: Achieves time synchronization within minutes.
  • Network Resilience: Maintains accurate time even with intermittent or poor network connections.
  • High Accuracy: Corrects time drift with precision.
  • Security: Offers better protection against certain types of NTP attacks.
  • Versatility: Functions as both an NTP client and server.

Prerequisites

  • A Linux system (RHEL, CentOS, Ubuntu, Debian, Fedora, etc.)
  • Root or sudo privileges
  • Basic knowledge of Linux terminal commands

How to Install and Use Chrony in Linux

Step 1: Installing Chrony

Installing Chrony is straightforward and can be done using package managers such as yum, dnf, or apt depending on your Linux distribution.

Install Chrony on RHEL/CentOS 7/8/9 and Fedora

sudo yum install chrony

Or for newer distributions:

sudo dnf install chrony

Install Chrony on Ubuntu/Debian

sudo apt update
sudo apt install chrony

Step 2: Starting and Enabling Chrony

Once installed, start and enable the Chrony service to ensure it runs at boot.

sudo systemctl start chronyd
sudo systemctl enable chronyd

To verify the status of Chrony:

sudo systemctl status chronyd

Step 3: Configuring Chrony

Chrony’s configuration file is typically located at /etc/chrony/chrony.conf or /etc/chrony.conf depending on the distribution.

Basic Configuration

Edit the configuration file using a text editor:

sudo nano /etc/chrony/chrony.conf

Add or modify the NTP servers:

server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst
  • iburst: Speeds up the initial synchronization process.

Save the file and restart Chrony for the changes to take effect:

sudo systemctl restart chronyd

Step 4: Verifying Time Synchronization

After configuring Chrony, verify that it is synchronizing correctly.

chronyc tracking

This command displays details about the system clock and the NTP sources. To see a list of NTP sources:

chronyc sources

You can also check the time synchronization status with:

timedatectl

Step 5: Using Chrony as an NTP Server

Chrony can act as an NTP server to synchronize other devices in the network. How to Install and Use Chrony in Linux

Enable NTP Server Mode

Edit the configuration file:

sudo nano /etc/chrony/chrony.conf

Add the following line to allow other clients to query the time:

allow 192.168.1.0/24

This allows clients in the 192.168.1.0/24 subnet to synchronize with your server. Restart Chrony to apply the changes:

sudo systemctl restart chronyd

Step 6: Monitoring Chrony

Chrony offers several commands to monitor its operation:

  • chronyc tracking – Shows the current time source and offset.
  • chronyc sources – Lists the configured NTP sources and their statuses.
  • chronyc sourcestats – Displays statistics about each NTP source.
  • chronyc ntpdata – Provides detailed information about each NTP source.

Troubleshooting Common Issues

  1. Chrony Not Synchronizing
    • Ensure the NTP servers are reachable:ping 0.pool.ntp.org
    • Verify Chrony is running:sudo systemctl status chronyd
  2. Clock Skew
    • Force synchronization:sudo chronyc makestep
  3. Firewall Blocking NTP
    • Allow NTP traffic through the firewall:sudo firewall-cmd --add-service=ntp --permanent sudo firewall-cmd --reload

Benefits of Using Chrony Over NTPD

  • Faster convergence time
  • Better handling of intermittent connections
  • Security enhancements
  • Smaller resource footprint

You can find Linux Tutorials on this page

You can also find all Video Tutorial on Youtube

Conclusion

Chrony is an essential tool for maintaining accurate time in Linux systems. Its speed, resilience, and accuracy make it a preferred choice over traditional NTP daemons. By following this guide, you can ensure your system clock remains synchronized, enhancing the reliability and performance of your applications and network services. How to Install and Use Chrony in Linux

Follow us on Facebook Twitter X Reddit Quora Linkedin Tubmblr Youtube


Share

Leave a Reply

Your email address will not be published. Required fields are marked *

?>