CentOS Linux Install and Configure NTP to Synchronize The System Clock

Posted on in Categories , , last updated November 13, 2013

How do I install and configure NTP under CentOS Linux version 5.x or 6.x server to synchronize the system clock?

You can easily install NTP (Network Time Protocol, a means of transmitting time signals over a computer network) using the yum command under Red Hat or CentOS/Fedora Linux server or workstation based systems. You need to install the following packages:

  1. ntp : ntpd server which continuously adjusts system time and utilities used to query and configure the ntpd daemon.
  2. ntpdate : Utility to set the date and time via NTP.
  3. ntp-doc : NTP documentation

Procedure: Setup NTPD on CentOS Linux

Open the terminal or login over the ssh session. You must login as as the root user. Type the following yum command to install ntp
# yum install ntp ntpdate ntp-doc

Turn on service, enter:
# chkconfig ntpd on

Synchronize the system clock with 0.pool.ntp.org server (use this command only once or as required):
# ntpdate pool.ntp.org

Start the NTP server. The following will continuously adjusts system time from upstream NTP server. No need to run ntpdate:
# /etc/init.d/ntpd start

Configure ntpd (optional)

Edit /etc/ntp.conf, enter:
# vi /etc/ntp.conf
Set public servers from the pool.ntp.org project:

server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org

See this tutorial on how to configure NTPD for LAN based client on RHEL / CentOS Linux for more information.

40 comment

  1. I did ntpdate 0.asia.pool.ntp.org
    and now all my servers showing different time. Any idea why
    server1 – Wed Jan 6 15:54:10 IST 2010
    server2 – Wed Jan 6 15:47:39 IST 2010
    server3 – Wed Jan 6 15:58:23 IST 2010

    For more infomation – My servers are in India
    Thanks in advance

  2. @Kunal,

    My guess: You are obtaining your time info from a pool, so each time you synchronize you’re really getting your time form a different server. This shouldn’t matter, but it seems that the different servers in that pool are not synchronized with each other. You could pick a single server out of the pool and synchronize with it directly on each of your servers.

    Or, even better, set up your own ntp server, have it synchronize with a quality outside time server, then have the rest of your servers sync up with the time server that you installed. That way, even if there’s an accuracy problem upstream, at least all of your servers will agree with each other.

    1. This is likely related to the server being a virtual server. It is not possible to sync to ntp in a VPS because the clock is inherited from the hardware that you are hosted on.

      I just ran across the same problem.

  3. Replying @Anonymous June 4, 2010

    Actually if you mean a Xen VM, you still can have your own independent system clock setting the following sysctl parameter.
    sysctl -w xen.independent_wallclock = 1;

    And you save it inside /etc/sysctl.conf

  4. i have configured ntp server on my machine which runs rhel6
    but at the client side at the time of ntp setting it giving me error tha
    server is note reachable or doesn’t act as a ntp server and also i cant
    see the port of ntp is open on my system, will you please help me for this

    Thanks

  5. You dont need to have an ntp server running in your machine in order to have the time synced, it is as easy as having cron do the syncing with the ‘ntpclient’ command.

  6. Hi,

    I’m having a small issue on Fedora 21: when my computer goes to sleep, I lose time synchronization and have to manually restart ntpd when I wake it in order to resync. Any idea how to fix this?

Leave a Comment