+3 votes
436 views
How it works, install and use Chrony Linux (Network Time Protocol NTP)

in Linux / Unix by (552k points)
reopened | 436 views

1 Answer

+4 votes
Best answer

1. How to install Chrony on Linux
2. How to check Chrony sync
3. How to configure Chrony on Linux

One of the most important aspects on any server, regardless of the operating system used, is the time ; Since many services, processes and applications depend on this and if the time fails in just one second we can be giving rise to a major problem in various aspects, not only at the system level but also at the administration level..

To help keep these time aspects in Linux at the best standards, a protocol called NTP (Network Time Protocol) has been developed, which is a protocol that runs through port 123 UDP in the Transport layer and its function is to allow the teams to synchronize the time in the networks to obtain a precise time. In addition to this we have a utility called Chrony, which is ideal to make the best use of everything that NTP gives us.

It is for this reason that through this tutorial TechnoWikis will explain in detail how to install and use Chrony on Linux..

What is chrony?
The Chrony utility is defined as a dynamic implementation of the Network Time Protocol (NTP), which allows us to synchronize the system clock with NTP servers, reference clocks and manual input through the keyboard. In addition, Chrony can also be used as an NTPv4 server (RFC 5905) for the purpose of providing a time service to other computers on the network.

Thanks to its versatile Chrony design, it can function correctly in various conditions, including intermittent network connections, congested networks, variable temperatures and systems that do not run continuously or run in a virtual machine, thus allowing data generated from Time is always correct.

Chrony includes two programs that are:

Chronyd
Which is a demon that can be started at boot time.
Chronyc
Which is a command line interface program that can be used to monitor Chronyd's performance and to change various parameters during execution as needed.

Chrony can be installed on operating systems such as Linux, FreeBSD, NetBSD, macOS, and Solaris.


1. How to install Chrony on Linux


Step 1

In some distributions of Linux, Chrony is already installed by default, if not, we can use any of the following lines for installation:
CentOS / RHEL
 yum -y install chrony 
Debian / Ubuntu / Mint
 apt install chrony 
Fedora
 dnf -y install chrony 

Enter the letter "S" to confirm the download and installation of Chrony, in this case in Ubuntu 18 Server..

image
Step 2

Then, we can check the status of Chrony with the following lines:
 systemctl status chronyd (SystemD) /etc/init.d/chronyd status (Init) 
image
Step 3

If you wish to enable the Chrony daemon at boot, we must use the following command:
 systemctl enable chrony (SystemD) chkconfig --add chronyd (Init) 
image

2. How to check Chrony sync


In order to verify if Chrony is carrying out its synchronization task correctly, we must make use of the chronyc command line program, which has the option of tracking with relevant information.
Step 1

To do this we execute the following:
 chronyc tracking 
image

The information generated is as follows:

Indicates the reference ID and the name with which the selected device is currently synchronized.
 Reference ID 
Refers to the number of jumps to a team using a reference clock attached.
 Stratum 
It is the UTC time in which the last measurement of the reference source used was made.
 Ref time (UTC) 
It is the system clock delay from the synchronized server.
 System time 
Indicates the offset of the last update of the NTP clock
 Last offset 
It is the long-term average of the time compensation value
 RMS offset 
It is the speed at which the system clock would be wrong in case chronyd does not adjust it. It is provided in ppm (parts per million)
 Frequency 
Indicates the difference between the measurements of the reference source and the frequency that is currently being used
 Freq Residual 
Refers to the estimated error limit of the frequency
 Skew 
It is the total of the network route delays to the equipment from which it is currently synchronizing.
 Root delay 
Indicates frequency dispersion by external and internal factors
 Root dispersion 
It is the update of the synchronization intervals
 Update Interval 
There the jump status is indicated, we have options such as normal, insert second, delete second or not synchronized
 Leap status 
If we want to get information about Chrony sources, we can use the following command
 chronyc sources 
image

3. How to configure Chrony on Linux


The chrony configuration file is hosted on the path:
 /etc/chrony.conf or /etc/chrony/chrony.conf 
The configuration file will look like this: image

There we have the following information:

It allows to describe an NTP server which will be the starting point for synchronization tasks
 Server 
It is the distance that must be added per stratum to the synchronization source. The default value is 0.0001
 Stratumweight 
Indicates the location and name of the file that contains drift data
 Driftfile 
Thanks to this directive, Chrony is allowed to gradually correct the time compensation during the process of accelerating or slowing down the clock as necessary.
 Makestep 
It is the path to the chron log file
 Logdir 
To advance the system clock immediately and ignore any current setting, we must use the following command
 chronyc makestep 

To stop the Chrony service we can use any of the following lines:

SystemD
 systemctl stop chrony 
Init
 /etc/init.d/chronyd stop 

Thanks to Chrony we can be sure that our server will be within the correct time range according to our location.


by (3.5m points)
edited

Related questions

+4 votes
1 answer
asked Oct 16, 2019 in Linux / Unix by backtothefuture (552k points) | 286 views
+3 votes
1 answer
+4 votes
1 answer
asked Nov 1, 2019 in Linux / Unix by backtothefuture (552k points) | 327 views
+3 votes
1 answer
asked Oct 18, 2022 in Linux/Unix by backtothefuture (552k points) | 75 views
+4 votes
1 answer
asked Oct 9, 2019 in Linux / Unix by backtothefuture (552k points) | 479 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users