How to Sync Time in AlmaLinux 8 using Chrony
Install Chrony on AlmaLinux 8
yum install chrony -y
Configuration File of Chrony
Configuration file for Chrony is “/etc/chrony.conf”. The file looks like below.
cat /etc/chrony.conf
Output:
[root@vps ~]# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
pool 2.cloudlinux.pool.ntp.org iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
[root@vps ~]#
Testing Chrony
we can use chronyd to sync time of our AlmaLinux 8 server with remote NTP server manually.
chronyd -q 'server 0.europe.pool.ntp.org iburst'
Output:
[root@vps ~]# chronyd -q 'server 0.europe.pool.ntp.org iburst'
2021-03-23T18:18:13Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
2021-03-23T18:18:13Z Fatal error : Another chronyd may already be running (pid=658), check /var/run/chrony/chronyd.pid
[root@vps ~]#
Start and Enabled Chronyd Service
To start and enable chronyd using following commands.
systemctl start chronyd
systemctl enable chronyd
systemctl status chronyd
Output:
[root@vps ~]# systemctl start chronyd
[root@vps ~]# systemctl enable chronyd
[root@vps ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-03-23 14:09:24 EDT; 11min ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Main PID: 658 (chronyd)
Tasks: 1 (limit: 11451)
Memory: 2.5M
CGroup: /system.slice/chronyd.service
└─658 /usr/sbin/chronyd
Mar 23 14:09:24 vps.server.com systemd[1]: Starting NTP client/server...
Mar 23 14:09:24 vps.server.com chronyd[658]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS >
Mar 23 14:09:24 vps.server.com chronyd[658]: Frequency 17.381 +/- 1.650 ppm read from /var/lib/chrony/drift
Mar 23 14:09:24 vps.server.com chronyd[658]: Using right/UTC timezone to obtain leap second data
Mar 23 14:09:24 vps.server.com systemd[1]: Started NTP client/server.
Mar 23 14:09:37 vps.server.com chronyd[658]: Selected source 50.205.244.20
Mar 23 14:09:37 vps.server.com chronyd[658]: System clock TAI offset set to 37 seconds
lines 1-18/18 (END)
Verify and Track Chrony Synchronization
To verify whether your system’s time is synchronized using chrony.
chronyc tracking
Output:
[root@vps ~]# chronyc tracking
Reference ID : 32CDF414 (ntp1.doctor.com)
Stratum : 3
Ref time (UTC) : Tue Mar 23 18:20:24 2021
System time : 0.000295571 seconds fast of NTP time
Last offset : +0.000090150 seconds
RMS offset : 0.000639843 seconds
Frequency : 17.997 ppm fast
Residual freq : +0.010 ppm
Skew : 0.822 ppm
Root delay : 0.046430726 seconds
Root dispersion : 0.019498281 seconds
Update interval : 64.5 seconds
Leap status : Normal
[root@vps ~]#
Check Chrony Sources
To list information about the current time sources that the chronyd is using.
chronyc sources
Output:
[root@vps ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ time100.stupi.se 1 6 377 53 +733us[ +823us] +/- 79ms
^* ntp1.doctor.com 2 6 377 53 +572us[ +662us] +/- 50ms
^+ 101-100-138-250.myrepubl> 2 6 377 50 -1121us[-1121us] +/- 92ms
^+ 5.103.128.88.static.fibi> 1 6 377 51 -2975us[-2975us] +/- 72ms
[root@vps ~]#
Check Chrony Source Statistics
To list the information about drift speed and offset estimation of each source that the chronyd is using.
chronyc sourcestats -v
Output:
[root@vps ~]# chronyc sourcestats -v
210 Number of sources = 4
.- Number of sample points in measurement set.
/ .- Number of residual runs with same sign.
| / .- Length of measurement set (time).
| | / .- Est. clock freq error (ppm).
| | | / .- Est. error in freq.
| | | | / .- Est. offset.
| | | | | | On the -.
| | | | | | samples. \
| | | | | | |
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
192.36.143.130 6 3 323 -1.353 7.090 +625us 238us
ntp1.doctor.com 10 6 582 +0.018 0.597 +756us 57us
101-100-138-250.myrepubl> 15 8 720 -0.287 1.652 -1281us 340us
5.103.128.88.static.fibi> 15 7 719 -0.794 6.161 -1222us 1287us
[root@vps ~]#
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS