NTPD is a very useful daemon to keep your system's clock (the normal clock - ie. hh:mm:ss, not the cpu one!), synchronized with a remote Time Server.

Why is this important at all? Well, for one, you might wish to make sure that the file changes are consistent with the current date & time.

Let's say your clock is (wrongly) set to a future date. Let's also assume you use rsync to keep in sync two network folders.

If you edit a file, then adjust the clock and edit it again, your rsync might not consider the file as "newer" and won't sync it.

The above is just an example.

On Windows for example, there are other issues to be aware of (such as Kerberos tolerance to 5mins. skew by default).

In conclusion:

  • Keeping your OS time current is of utter importance.

Install ntpd.

Here's how to install and configure the ntpd (server) daemon on CentOS LINUX.

yum -y install ntp
rpm --list | grep ntp
mv /etc/ntp.conf /etc/ntp.conf.ori

Configure ntpd.

Edit /etc/ntp.conf w/your fav editor:

# Choose your fav, 2nd-tier Time Server(s) from this website: http://goo.gl/6cd7C
# The following are good Australian TSs:
server qbert.enlartenment.com
server ntp2.tpg.com.au
server 202.83.82.162
server 203.26.24.6

# The following are good Italian TSs:
server 193.204.114.232
server 193.204.114.233
server ntp1.inrim.it
server ntp2.inrim.it

# If you wish to restrict ntpd access to only a specific Subnet, enable (ie. uncomment) the following feature:
# restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap
multicastclient
#

As initially explained, copy/paste the above config sections to your /etc/ntp.conf then save and close.

 

How to AutoStart ntpd.

On a root terminal run:

chkconfig ntpd on
/etc/init.d/ntpd restart

The 1st command will autostart ntpd at boot (runlevels 3,4 and 5) while the 2nd will start the daemon right now!

 

Synch time immediately.

How to immediately synchronise time.

On a root terminal, run:

/etc/init.d/ntpd stop

  • To stop the ntpd daemon.
  • Then:

ntpdate -s -b -p 8 -u oceania.pool.ntp.org

  • "ntpdate" will Synch time while the daemon is not running.
  • Finally run:

/etc/init.d/ntpd start

To restart the ntpd daemon.

 

Synch time command explanations:

-b

Forces the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time.

-p samples

Specifies the number of samples to be acquired from each server as the integer samples, with values from 1 to 8 inclusive. The default is 4.

-s

Diverts logging output from the standard output (default) to the system syslog facility. This is designed primarily for cron scripts convenience.

-u

Direct ntpdate to use an unprivileged port or outgoing packets. This is most useful when behind a firewall that blocks incoming traffic to privileged ports, and you want to synchronise with hosts beyond the firewall. Note that the -d option always uses unprivileged ports.

 

SRC:

http://www.akadia.com/services/ntp_synchronize.html

3.1/5 - (15 votes)