How to install and configure NTP to synchronize the system clock in CentOS/RedHat Linux

Before synchronizing your Linux box to a NTP server you should assure it is correctly set to your current timezone.
Setting the timezone on CentOS or Redhat Enterprise Linux (RHEL) is straightforward.

1. See what the current timezone is:

# date

You should see something like this:

mar nov 13 14:53:56 CET 2012

where CET stands for “Central European Time”.

2. To change the timezone first look at what timezones are available by running the following command on the command line interface:

# ls /usr/share/zoneinfo/

You’ll get something like this:

[root@server ~]# ls /usr/share/zoneinfo/
Africa      Asia       Canada   Cuba   EST      Factory  GMT0       Hongkong  Iran         Japan      Mexico   Navajo   Poland      PRC      ROK        Universal  W-SU
America     Atlantic   CET      EET    EST5EDT  GB       GMT-0      HST       iso3166.tab  Kwajalein  Mideast  NZ       Portugal    PST8PDT  Singapore  US         zone.tab
Antarctica  Australia  Chile    Egypt  Etc      GB-Eire  GMT+0      Iceland   Israel       Libya      MST      NZ-CHAT  posix       right    Turkey     UTC        Zulu
Arctic      Brazil     CST6CDT  Eire   Europe   GMT      Greenwich  Indian    Jamaica      MET        MST7MDT  Pacific  posixrules  ROC      UCT        WET

3. Delete the current timezone:

rm /etc/localtime

4. Make a symbolic link to the new timezone file:

# ln –s /usr/share/zoneinfo/America/New_York /etc/localtime

Now it’s time to synchronize the system clock to a NTP server.
Network Time Protocol (NTP) is a standard way of synchronizing computer clocks across a network. Using NTP you can keep your server’s clock synchronized with super accurate atomic clocks located around the world. Computer clocks tend to “drift” so regularly synchronizing them with NTP servers helps keep them accurate.

5. Install if necessary the ntp tools:

# yum install ntp

6. Synchronize to the NTP server:

# ntpdate 0.us.pool.ntp.org

You can either use any public NTP server available worldwide or your own server connected to your LAN. You can find a complete list of public NTP servers at http://www.ntp.org

6. In order to maintain the system clock synchronized over time, it is highly recommended to start the NTP daemon which will correct the drifts between your server and the NTP server’s clock. Edit /etc/ntp.conf and set the correct server to use:

server 0.us.pool.ntp.org

Don’t forget to comment out the following lines that can prevent ntpd to synchronize properly with the server:

#server 127.127.1.0     # local clock

#fudge  127.127.1.0 stratum 10

7. Start NTPD service up:

# service ntpd start

8. Make it run automatically at boot up:

# chkconfig ntpd on

9. Last but not least, “save” your current time to your hardware clock:

# hwclock --systohc
Advertisements

One thought on “How to install and configure NTP to synchronize the system clock in CentOS/RedHat Linux

  1. Hello admin, i found this post on 11 spot in google’s search results.
    I’m sure that your low rankings are caused by hi bounce rate.
    This is very important ranking factor. One of the biggest reason for high bounce
    rate is due to visitors hitting the back button. The higher your
    bounce rate the further down the search results your posts and pages will end up, so having reasonably low bounce rate is important for
    improving your rankings naturally. There is very handy wordpress plugin which
    can help you. Just search in google for:
    Seyiny’s Bounce Plugin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s