NTP (Network Time Protocol) is a protocol utilized to synchronize the clock time of a computer with a remote NTP server over a network. The purpose of NTP in CentOS is to ensure that the system clock of a server or other networked device is accurate and consistent across the network. It is important for various services and applications that rely on accurate time, such as authentication, logging, and scheduling.
This article will illustrate the step-by-step instructions to force an NTP sync with the NTP server in CentOS.
- Force an NTP sync with the NTP Server in CentOS
- Stop the ntpd service
- Forcefully Synchronize with the NTP Server
- Restart the ntpd service
- Verify NTP sync with the NTP Server
How to Force an NTP sync with the NTP Server in CentOS?
To force an NTP sync with the NTP server in CentOS, you can use the “ntpdate” command. This command synchronizes the system time with a remote NTP server.
Step 1: Stop the ntpd Service
The “ntpd” service is installed by default in the operating system. It is necessary to stop the NTP sync to start the synchronization with the NTP server. To stop the ntpd services from the system, utilize the “systemctl” command with the “stop” utility as below:
$ sudo systemctl stop ntpd
The output shows that “ntpd” services have been stopped.
Step 2: Forcefully Synchronize With the NTP Server
To synchronize the system clock with an NTP server in CentOS, use the “ntpdate” command with the server address. For instance, synchronize with the NTP server at “pool.ntp.org”:
$ sudo ntpdate -bv pool.ntp.org
The output shows synchronization with the NTP server “pool.ntp.org” has been done.
Step 3: Restart the ntpd Service
To restart the ntpd services, the “systemctl” command is utilized with the “start” utility as below:
$ sudo systemctl start ntpd
The above command takes some time to start the ntpd services.
Step 4: Verify NTP Sync With the NTP Server
To verify the NTP synchronization with the NTP server, execute the “ntpq” command with the “p” option as below:
$ sudo ntpq -p
The output shows that the NTP has been successfully synced with the NTP server.
CentOS offers the “ntpdate” command in combination with the “ntpd” service to forcefully synchronize the NTP server. Before doing so, ensure that the “ntpd” service is stopped. This post has provided a set of sequential steps to force an NTP sync with the NTP server in CentOS.