How to Sync Time using NTP in the Ubuntu Server?

Linux server users might have noticed that after adjusting the system clock to the correct time, the server loses the right time within a few moments. 

Keeping your system's time up to date is essential, especially when you have time-critical cron tabs to execute or must examine the logs from a particular time of the day. That's when the network time protocol (NTP) comes into the picture. 

This article will explain how to set up an NTP server on your machine to adjust its clock regularly.

Network Time Protocol

Network time protocol (NTP) lets you periodically synchronize your server's system time with a remote server. Thus, you can keep your system time accurate by syncing with the known time servers.

How do I Install NTP Server?

To install the NTP server, issue the following command – 

For Ubuntu/Debian

sudo aptitude update
sudo aptitude install ntp

Set NTP service to run at boot time

Once the NTP server is installed, ensure that the service will run at boot time by running this command – 

sudo /sbin/chkconfig ntpd on

Start the NTP Service

To make sure the NTP service starts after installing, issue the following command – 

sudo /etc/init.d/ntp start 

By installing the NTP service, your server is automatically set up to sync time with default NTP servers.

Was this answer helpful?

« Back