RHEL 7 comes preinstalled with Chrony. While everybody knows Ntpd, Chrony is a newcomer to the game of timekeeping.
Chrony is a set of programs that maintains the time on your computer using different time sources, such as NTP servers, your system's clock, and even custom-made scripts/programs. It also calculates the rate at which the computer loses or gains time to compensate while no external reference is present—for example, if your NTP server(s) is(are) down.
Chrony is a good solution for systems which are intermittently disconnected and reconnected to a network.
Ntpd should be considered for systems that are normally kept on permanently.
When talking about managing time in RHEL, it can be done through:
We'll take a look at each of the methods separately.
Ensure that chrony
is installed and enabled, and perform the following steps:
chrony
through the following command:~]# yum install -y chrony
chrony
, as follows:~]# systemctl enable chrony ~]# systemctl start chrony
/etc/chrony.conf
with your favorite editor and look for lines starting with the server
directive using the following commands:server 0.rhel.pool.ntp.org iburst server 1.rhel.pool.ntp.org iburst server 2.rhel.pool.ntp.org iburst server 3.rhel.pool.ntp.org iburst
server 0.pool.ntp.mydomain.lan iburst server 1.pool.ntp.mydomain.lan iburst
The iburst
option causes NTP to send a burst of eight packets at the next poll instead of just one if the time master is unavailable, causing the NTP daemon to speed up time synchronization.
chrony
by executing the following command:~]# systemctl restart chrony
Ensure that ntpd
is installed and enabled, and perform the following steps:
ntpd
by running the following:~]# yum install -y ntpd
ntpd
through this command:~]# systemctl enable ntpd
/etc/ntp.conf
with your favorite editor and look for the lines starting with the server
directive. Run the following:server 0.rhel.pool.ntp.org iburst server 1.rhel.pool.ntp.org iburst server 2.rhel.pool.ntp.org iburst server 3.rhel.pool.ntp.org iburst
server 0.pool.ntp.mydomain.lan iburst server 1.pool.ntp.mydomain.lan iburst
/etc/ntp/step-tickers
with all your NTP servers, one per line:0.pool.ntp.mydomain.lan 1.pool.ntp.mydomain.lan
ntpd
by executing the following:~]# systemctl restart ntpd
While ntpd
is the obvious choice for time synchronization, it doesn't fare well in environments where time masters are intermittently accessible (for whatever reason). In these environments, chronyd
thrives. Also, ntpd
can be quite complex to configure correctly, whereas chronyd
is a little bit simpler.
The reason for modifying /etc/ntp/step-tickers
when using the ntpd
file is for the startup of the service. It uses ntpdate
to synchronize time in one step before actually starting the NTP daemon itself, which is a lot slower in synchronizing time.
To figure out whether your system is synchronized, use the following command:
chrony
, use the following command:~]# chronyc sources
ntpd
, run the following:~]# ntpq -p
Your output will be similar to:
remote refid st t when poll reach delay offset jitter ===================================================================== LOCAL(0) .LOCL. 5 l 60m 64 0 0.000 0.000 0.000 *master.exam 178.32.44.208 3 u 35 128 377 0.214 -0.651 14.285
The asterisk (*
) in front of an entry means that your system is synchronized to this remote system's clock.
For more information on configuring chrony
for RHEL 7, go to https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-Configuring_NTP_Using_the_chrony_Suite.html.
For more information on configuring ntpd
for RHEL 7, go to https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-Configuring_NTP_Using_ntpd.html.