How to Keep Your Server Time In Sync with NTP

As the expression goes, timing is everything. When it comes to automating tasks, monitoring logs, and performing updates on your server, timing is very important. Your server is just like any other computer in the way it keeps time. By default, it has an internal clock that you can set at the Bios level and at the OS level. Once the clock is set, it should maintain a steady time.

In reality, however, things can happen to cause the time to get out of sync. Furthermore, it may not have been exactly in sync in the first place. Network Time Protocol (NTP) allows you to sync dedicated servers over a network and over the Internet to make sure they all have the same time. With a Linux or Unix server, you can set it to use NTP to automatically keep in sync with a global time server.

In CentOS and other Red Hat-based distributions, there is a package called “ntp” that will allow you to keep your server in sync with Coordinated Universal Time (UTC) using the Network Time Protocol. First, you need to install ntp if it is not already on your system.

yum install ntp

Next, set the service to automatically start at bootup

chkconfig ntpd on

Then, synchronize your clock with the NTP server.


Finally, start the ntp service on your computer:

/etc/init.d/ntpd start

Once NTP is running, your system’s clock should stay in sync based on the timezone settings you have in place. As long as it is connected to the Internet, which a server always should be, your time will be correct.