How to configure NTP client in CentOS

What's NTP?

NTP stands for Network Time Protocol, and it is an Internet protocol used to synchronize the clocks of computers to some time reference. NTP is an Internet standard protocol originally developed by Professor David L. Mills at the University of Delaware.


First thing to do is to set your time zone:

Before we make any changes let's check what time zone your system is on by using the date command:

 

$ date
Fri Jun 6 17:58:07 EST 2013


If this is not the right time zone then you can change it by moving a few files around. Let's first take a backup of /etc/localtime and then replace it with the one with our correct time zone.
You should be able to find your time zone here: /usr/share/zoneinfo
By browsing through the subdirs you'll find your city.

mv /etc/localtime /etc/localtime.bk
cp /usr/share/zoneinfo/America/New_York /etc/localtime


Now verify that you set it properly again with the date command like we did above.

 

Install and Setup NTP on CentOS Linux
Now that our machine has the correct timezone, let’s sync the time with an NTP server.

First install the NTP packages with yum

# yum install ntp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* Webmin: download.webmin.com
* base: mirror.tocici.com
* extras: mirror.san.fastserv.com
* rpmforge: mirror.hmc.edu
* updates: mirrors.sonic.net
Webmin | 951 B 00:00
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
rpmforge | 1.9 kB 00:00
updates | 3.4 kB 00:00
vz-base | 951 B 00:00
vz-updates | 951 B 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntp.i686 0:4.2.6p5-1.el6.centos will be installed
--> Processing Dependency: ntpdate = 4.2.6p5-1.el6.centos for package: ntp-4.2.6p5-1.el6.centos.i686
--> Running transaction check
---> Package ntpdate.i686 0:4.2.6p5-1.el6.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch
================================================================================
Installing:
ntp i686
Installing for dependencies:
ntpdate i686

Transaction Summary
================================================================================
Install 2 Package(s)

Total download size: 660 k
Installed size: 1.7 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): ntp-4.2.6p5-1.el6.centos.i686.rpm
(2/2): ntpdate-4.2.6p5-1.el6.centos.i686.rpm
--------------------------------------------------------------------------------
Total
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ntpdate-4.2.6p5-1.el6.centos.i686 1/2
Installing : ntp-4.2.6p5-1.el6.centos.i686 2/2
Verifying : ntp-4.2.6p5-1.el6.centos.i686 1/2
Verifying : ntpdate-4.2.6p5-1.el6.centos.i686 2/2

Installed:
ntp.i686 0:4.2.6p5-1.el6.centos

Dependency Installed:
ntpdate.i686 0:4.2.6p5-1.el6.centos

Complete!


Our NTP package is now installed. Let’s set it to startup at boot time:



   # chkconfig ntpd on
   # chkconfig –list ntpd
   ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

 

Then simply sync with one of the NTP servers available:

# ntpdate -db 0.north-america.pool.ntp.org


you can pick one from here:


http://www.pool.ntp.org/en/

 

This should be it!

  • 44 Utenti hanno trovato utile questa risposta
Hai trovato utile questa risposta?

Articoli Correlati

ownCloud Auto Install Script on Debian 7

Here is an easy way to install ownCloud on Debian 7 with a script, but first, for those who...

NGINX – Allow access only to certain IPs

Nginx has a nice module that not many people know about, it basically enables us...

Initial Server Setup on CentOS 6

Here are some recommendations to setup your VPS or server when you first get it, some of these...

How To Install nginx on CentOS

What is NGINX? Nginx (pronounced "engine-x") is an open source reverse proxy server for HTTP,...

How to connect to Linux via SSH using PuTTY

Download PuTTY Download PuTTY from the website.  Be sure to comply with the license...