Sunday, August 19, 2012

Install and run NTP on Centos

Having an accurate clock on your system is usually important. It ensures the time stamps in emails sent from the machine are correct, and it is especially helpful when you need to look at the logs from a particular time of day.

Network time protocol

That's where the network time protocol (NTP) comes in. NTP lets you automatically sync your system time with a remote server. Setting up an NTP server to regularly adjust your machine's clock is pretty easy by default. It's also possible to make it a bit more complicated if you need your clock accurate down to the millisecond instead of just to the second.


The first thing to do is install the NTP server.
Grab the package by running:
sudo yum install ntp

Once it's installed you can ensure the service will run at boot time by running:
sudo /sbin/chkconfig ntpd on

Start the service
To make sure the NTP service starts after installing it, run:
sudo /etc/init.d/ntpd start

As is usual for Linux services, you can stop or restart the NTP service by running the above command with "stop" or "restart" sent as the argument instead of "start".
Your system time is now served by NTP.

Fine Tuning

The ntp.conf file.The NTP configuration file can be found at:


There are a few settings that can be changed in there, but for most people the only settings of interest would be any "server" entries.
The default for CentOS looks like:

# Use public servers from the project.
# Please consider joining the pool (

With more than one "server" entry your NTP server will query all servers and only select a time that a majority of the polled servers will agree on. This basically means that with three or more servers your clock will be more accurate than if it just uses one. If you add the "iburst" option after the server address it can speed up the NTP time sync by a bit. It's usually a good idea to use it, but not essential.

Further Reading:

No comments:

Post a Comment