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.
• A server with CentOS 6
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.
Try editing your NTP config. Open the file with a text editor, and add the NTP server you would like to use.
You can also set which public servers you’ll use from the pool.ntp.org project.
Now you can start the ntpd server for automatic time updating.
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.