HomeLinuxHow to Synchronize Time with NTP in Linux Using Chrony Tool

How to Synchronize Time with NTP in Linux Using Chrony Tool

In Linux-based operating systems and servers, the time zone and timestamps play a vital role in optimization and server management. If you are a server admin, you probably already know that changing the server timestamp can play a critical role in making your server accessible from various locations. If your Linux machine’s time is not synchronized correctly, your system might not get the appropriate package update. To avoid this hassle, you can use the NTP (Network Time Protocol) on your Linux machine to synchronize your machine’s time.

Synchronize Time with NTP in Linux


Every operating system has its method to keep the machine’s time accurate and perfect according to the time zone. In Linux, the job of keeping your machine’s time accurate is done by Chrony. Chrony is Network Time Protocol for Debian, Red Hat, Arch, and other Linux distributions that can Synchronize time over a network protocol.

Chrony has its daemon to run silently on your Linux machine. The Red Hat software developers built Chrony; now, it is used widely for all Linux-based operating systems. It is written in the C programming language, and it has the GNU privacy license. This post will show you how to Synchronize Time with NTP in Linux using the Chrony (NTP) tool.

Step 1: Install Chrony on Linux


The very first step is installing Chrony on Linux. It is easy to install on Debian, Red Hat, servers, and other Linux distributions from the official Linux repository. If you’re a Debian/Ubuntu Linux user, you can run the following aptitude command given below to install Chrony on your system.

sudo apt-get install chrony

Install chrony on Linux

If you’re a Red Hat or Fedora Linux user, you can install Chrony by running the following DNF or YUM command on your terminal shell.

Install Chrony On Red Hat Linux

sudo yum install chrony

Install Chrony on Fedora Linux

sudo dnf install chrony

After a successful installation of Chrony on your Linux machine, you can now enable it and check the status of Chrony on your machine. Run the following system control commands chronologically on your Linux terminal shell to enable and see the system status.

# systemctl enable --now chronyd
# systemctl status chronyd

chrony status check

You can also run the following command to check the Chrony activity on your Linux machine.

# chronyc activity

Step 2: Monitor Chrony Parameters on Linux


After installing the Chrony tool on your Linux, you can now monitor the source mode, source state, IP address, NTP sample rate from your terminal shell. Run the following command on your terminal shell with root privilege to check the Chrony parameters.

chronyc sources -v

Synchronize Time with NTP in Linux sources -v

You can also run the following sourcestats command on your terminal shell to monitor the number of sample points, frequency, network IP, NTP server address, and other detailed information about the NTP server on your Linux machine.

chronyc sourcestats -v

Step 3: Configure Chrony To Synchronize Time


Chrony runs a daemon inside the system to synchronize time on a Linux system automatically through the NTP server. You can find the Chrony configuration script inside the /etc/chrony/chrony.conf file. To edit and configure the Chrony configuration, you can run the following command on your terminal shell. Here, I’m using the Nano script editor to edit the Chrony configuration script; you can use other editors as well.

sudo nano /etc/chrony/chrony.conf

Normally, NTP uses the pool 0.pool.ntp.org burst server to synchronize Time with NTP in Linux. But you can add the following NTP server addresses inside the configuration script to synchronize time with NTP in Linux.

server 0.europe.pool.ntp.org iburst
server 1.europe.pool.ntp.org iburst
server 2.europe.pool.ntp.org ibusrt
server 3.europe.pool.ntp.org ibusrt

Synchronize Time with NTP in Linux configuration

After configuring the NTP server addresses on your Linux system, don’t forget to restart the Chrony services on your machine. Run the following system control command to restart the Chrony daemon on your Linux machine.

sudo systemctl restart chrony

Step 4: Track Time via Chrony


Previously we have seen how to monitor Chrony parameters and how to configure the Chrony settings. We can now see the Chrony sources to monitor the Chrony daemon parameters. Run the following command on your terminal shell with root privilege to monitor the Chrony source.

# chronyc sources

You can also monitor the Chrony tracking records by running the following command on your shell.

# chronyc tracking

source stats tracking Synchronize Time with NTP in Linux

Finally, run the following timedatectl command on your terminal shell to display the current local time, universal time, RTC time, time zone, and the NTP server status on your Linux machine.

# timedatectl

Synchronize Time with NTP in Linux see time

Final Words


Synchronize time using network protocols in Linux is not a very hard process; rather, it’s a straightforward process. In the entire post, I have described why synchronizing time on a Linux machine is important and how to synchronize time with NTP in Linux. After doing everything right, if you find your machines’ time got unsynchronized after every restart, make sure the BIOS C-MOS battery functions perfectly.

Please share it with your friends and the Linux community if you find this post useful and informative. You can also write down your opinions regarding this post in the comment section.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

spot_img

Latest Post

Must Read