NTP on Oracle Linux 8
How to build and run NTP and not chronyd on Oracle Linux 8
NTP or Network Time Protocol is an old and vastly used protocol which is used to synchronize time on computers over the network. This protocol is stable and actively supported. But RHEL Linux 8(on which Oracle Linux 8 is based), NTP is no longer supported and is being replaced a new service called Chrony. The new service has no issues, but the purpose of this article is to describe how we can still use NTP on Oracle Linux 8. There can be many reasons for that such as:
- Old Software and build dependencies
- More support for NTP as this has been ported to many more Operating Systems
- Support for Multicast, Broadcast and Manycast of time which are not supported by Chrony but are supported by NTP.
The following are the assumptions for this article:
- You have installed 64 bit Oracle Linux 8 and have got root access
- You have basic knowledge of Linux System Administration
- You are familiar with Systemd Services.
Build NTP from Source
As NTP package or RPM is not provided from the official Oracle Linux 8,we will build it from source. Here are the steps to do this:
- Get the latest source code from http://www.ntp.org/downloads.html. Use the Production Release always.
- Copy the downloaded tar file to a Linux Machine which should have basic tools present by default.
- Compare the checksum of the tar file downloaded:-
The output should match with the value inside ntp-4.2.8p15.tar.gz.md5 file (which is also downloaded from the same link)
4. Extract the content:
tar -xvzf ntp-4.2.8p15.tar.gz
5. Change directory:
6. Prepare for compilation:
./configure CFLAGS="-O2 -g -fPIC" --prefix=/usr --bindir=/usr/sbin --sysconfdir=/etc --enable-linuxcaps -with-lineeditlibs=readline --docdir=/usr/share/doc/ntp-4.2.8p15
7. Build using:
8. Make will build all the NTP and related exes. These can be reduced in size using the following commands:
strip ntpdcd ../ntpdc/
strip ntpdccd ../util/
strip tickadjcd ../ntpq
strip ntpqcd ../ntpdate/
Now copy these files on to the target Oracle Linux 8 machine in the following locations, along with the permissions mentioned:
cp ntpd /usr/sbin/ntpd
chmod 755 /usr/sbin/ntpd
Do the same for other executables.
Setting up NTP Sytemd Service
Now we have the executables ready, we will register them as a service so that it can be managed and used via systemctl. For that first create a new file on the target at location
/etc/systemd/service with the following content.
Description=This service starts and control NTP Deamon
ExecStart=/usr/sbin/ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
Name this file as
ntpd.service . Replace XYZ.service with the service name after which you want to start the NTP service or else remove that “After=” line. Keep the permission of this file as 644:
chmod 644 /etc/systemd/service/ntpd.service
Disable the Chrony Service:
systemctl disable chronyd
Create user and directories for NTP Service:
useradd -r ntp -s /bin/nologin -m -d /etc/ntp
chown ntp:ntp /var/lib/ntp
Enable the NTP Service:
systemctl enable ntpd.service
Copy the previous NTP configuration or create the new desired one at location
/etc/ntp.conf with permission 644
Reboot the server and check the status of the newly created NTP Service using:
[root]# systemctl status ntpd.service
● ntpd.service - This service starts and control NTP Deamon
Loaded: loaded (/etc/systemd/system/ntpd.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-04-05 20:14:51 GMT; 3 weeks 1 days ago
Process: 752 ExecStart=/usr/sbin/ntpd -u ntp:ntp -p /var/run/ntpd.pid -g (code=exited, status=0/SUCCESS)
Main PID: 789 (ntpd)
Tasks: 2 (limit: 35799)
└─789 /usr/sbin/ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
Now use the basic NTP commands like
ntpq -pn to check the syncronization status etc.
After doing these steps you should be able to run NTP on Oracle Linux 8. These steps can also be easily automated using bash scripting and can also be integrated to any CI pipelines.
If you like this article, then please consider following me. Thanks for reading.