Hello everyone, in this article we will show you how to Synchronize time on Linux servers with Crony. Time plays an important role in Linux servers, especially when they are used in banking, stock market and other financial areas. If we want all our Linux servers to have the correct time, we need to configure an NTP client that always retrieves the correct time from remote NTP servers and makes the necessary adjustments to synchronize the time.
Accurate time is one of the most important configurations required for reliable communication between network-based computers. It is also required to ensure system components including systemd timers and cron jobs run on time. Computers can maintain accurate time by using the Network Time Protocol (NTP) to synchronize their time with an upstream time server.
Since many services such as cron jobs and scripts rely on accurate time to function as expected, it is important to keep the date and time accurate on a Linux system. Network Time Protocol, abbreviated as NTP, is a protocol that maintains accurate time on Linux systems. Below are 9 ways to synchronize time on Linux servers with Crony.
How to Synchronize time on Linux servers with Crony
Install Chrony on CentOS / RHEL / Fedora system
Step 1: To install Chrony on a CentOS, RHEL and Fedora machine, run the following yum or dnf command
~]# chrony -y to install yum or ~]# chrony -y to install dnf
Install Crony on Debian / Ubuntu system
Step 1: To install Chrony on Debian and Ubuntu systems, run the following apt command,
~]$ sudo apt install chrony -y
Step 2: Once Crony is installed on a Linux server it provides two programs,
- chronyc : This is the command line interface of chrony
- chronyd : This is the daemon for Chrony that starts and runs the Chrony service across reboots.
Crony’s configuration file
Step 1: The configuration file for Chrony is “/etc/chrony.conf”, sample chrony.conf file is listed below,
~]# cat /etc/chrony.conf
Testing the crony
Step 1: Similar to the ntpdate command in an NTP distribution, we can use chronyd to manually synchronize our Linux server’s time with a remote NTP server,
~]# chronyd -q ‘server 0.europe.pool.ntp.org iburst’
Start and run the chronit service
Step 1: Run the following commands to start and run the chronit daemon and it will be available across reboots.
~]# systemctl start chronyd
~]# systemctl enables chronyd
Step 2: Run below command to check chronys service status
Check and monitor crony synchronization
Step 1: To check if your computer’s time is synchronized using chrony, issue the following command,
[root@ceph-admin ~]# chronyc tracking Reference ID : 904C13DD (its.no-fun.de) Layer : 3 Reference time (UTC) : Sun Jan 12 06:23:26 2020 System time : 0.000174314 seconds Slow NTP time Last offset : -0.0.003 seconds Offset : 0.000199483 seconds Frequency : 0.301 ppm Fast Residual Frequency : -40.403 ppm Curve : 0.541 ppm Root Delay : 0.172664896 seconds Root Dispersion : 0.044736 seconds Root Dispersion : 0.0447364 seconds
- Reference ID is the ID and name of the server that your computer’s time is currently synchronized with.
- Stratum , which represents the number of hops away from the server with the associated reference clock.
Check the crony resources
Step 1: To list information about the current time sources used by chronyd, run the following command,
~]# Chronic resources
Step 2: To list detailed information about sources, run the following command
~]# chronyc sources -v
Check the crony source statistics
Step 1: Run the following command to list information about the drift velocity and offset estimate for each source used by chronid:
~]# chronyc sourcestats -v
Configure Crony NTP server
Step 1: Suppose you want to configure your Linux server as a Crony NTP server for all internal systems. To do this, we need to delete two lines from the “/etc/chrony.conf” configuration file.
- Local layer 10
- Allow 192.168.0.0/16
Step 2: Run the following commands
~]# sed -i “s/#local stratum 10/local stratum 10/g” /etc/chrony.conf ~]# sed -i “s/#allow 192.168.0.0/16/allow 192.168.0.0/16/ ” /etc/chrony.conf
Step 3: When we uncomment the line “local layer 10″, we turn our Linux server into a Crony NTP server and it works normally even if it is disconnected from the network. Whereas “allow 192.168.0.0/26” means that clients from this network are allowed to connect to our Chrony NTP server for time synchronization.
Step 4: After making the changes restart the Crony service and monitor the Crony
~]# systemctl restart chronyd ; See Chronic Tracking
Step 5: Enable the NTP service on the firewall using the following command,
~]# firewall-cmd –add-service=ntp –permanent ~]# firewall-cmd –reload
We hope you enjoy our article on Synchronizing Time on Linux Servers with Crony. Linux servers are one of the most widely used servers in the world for several reasons. Unlike Windows and other proprietary software, Linux is much cheaper and gives you more control over the configuration of your servers to get started. So if you like our article then share it with others.
About This Guide?
In this guide, we told you about the Sync time on Linux servers with Chrony; please read all steps above so that you understand Sync time on Linux servers with Chrony in case if you need any assistance from us, then contact us.
How this tutorial or guide assisting you?
So in this guide, we discuss the Sync time on Linux servers with Chrony, which undoubtedly benefits you.
Share this article about Sync time on Linux servers with Chrony
I hope you like the guide Sync time on Linux servers with Chrony. In case if you have any queries regards this article/tutorial you may ask us. Also, share your love by sharing this article with your friends and family.
#Sync #time #Linux #servers #Chrony