How to use Network Time Services on CentOS 6

Try it in our public cloud & Get $5 Credit

Way back in 1979, network time synchronization was one of the first applications of the internet demonstrated to the general public. Today, it is one of the most crucial services that computers take advantage of. The protocol for network time synchronization in common use is called NTP, or Network Time Protocol.

NTP works via a hierarchy of servers organized into different strata. Stratum 0 is reserved for devices that report the time accurately, such as atomic clocks. Stratum 1 contains servers that directly get their time from devices in Stratum 0, and thus has in theory the highest level of accuracy. Servers in Stratum 2 obtain their time from servers in Stratum 1, and the time thus propagates downward through the strata to a maximum depth of 15.

Using a Network Time Server (NTP) is a very good way to make sure that your server time is always accurate, as it will continuously adjusts system time from upstream NTP servers. Without an accurate time system like NTP, there would be no way to be sure that timestamps on files are correct, making tasks like automated backups, collaboration on group projects, and version control much more difficult and fraught with error.

This guide will show you how to set up the date and time on your CentOS 6 server using NTP.

Getting started

• A server with CentOS 6

Step-by-step guide

First, after making sure your system is fully up to date, install ntp and ntpdate. You will use the package manager yum for this.

yum install ntp ntpdate

ntp is used to have a continuously adjusted system time from upstream NTP server ntpdate is an utility to set the date and time via NTP.

Now you can adjust your system date and time using the following command. Run this one time, and then only when necessary in the future.

ntpdate pool.ntp.org

Try editing your NTP config. Open the file with a text editor, and add the NTP server you would like to use.

vim /etc/ntp.conf

You can also set which public servers you’ll use from the pool.ntp.org project.

server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org

Now you can start the ntpd server for automatic time updating.

/etc/init.d/ntpd start

You’ll probably want to have ntpd start automatically on system boot. Use this command to enable that feature.

chkconfig ntpd on


With accurate time reporting provided by ntpd, you can rest easy knowing that your system is in step with the rest of the internet. If you liked this KB article, please share it with your friends.