How to sync Linux server time with NTP (Network Time Protocol) server

Reference Server

In this tutorial we will learn to syncronize linux server time with NTP (Network Time Protocol) server.

What is NTP?

NTP or Network Time Protocol, is an Internet protocol used to synchronise clocks of computers, linux server for instance.

Following steps shows how to sync time using the terminal. Before we start login to the server via terminal and follow the steps given below.

Step 1: Check whether NTP is installed

Use the ntpstat command to view the status of the NTP service on the instance. If you get an error message prompting that NTP is not installed then you have to install it on the server.

# sudo ntpstat
-bash: ntpstat: command not found

Step 2: Install NTP

Use the following command to install NTP on server.

# sudo yum install ntp

Step 3: Start NTP

After the installation is complete we need to start NTP by using the following command.

# sudo systemctl start ntpd

Note!

To enable NTP to start at boot use the following command.

# sudo systemctl enable ntpd

To stop NTP use the following command.

# sudo systemctl stop ntpd

To restart NTP use the following command.

# sudo systemctl restart ntpd

Step 4: Sync Time

For this use the following command.

# sudo ntpdate -q 0.rhel.pool.ntp.org

And restart NTP

# sudo systemctl restart ntpd

And the server time will be synced.

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT