The right time on our servers is extremely important. We use the NTP (Network Time Protocol) to synchronize the clock of our servers to the internet and to each other. On this page we gathered our knowledge about setting up NTP.

First the NTP package need to be downloaded and installed. We use RedHat/Centos/Fedora most of the time, the package can be installed using the yum package manager with the following command.

yum install ntpd

Edit the /etc/ntp.conf file. Add your own servers. Use a NTP server as close as possible to your computer, this makes the error as small as possible. When you don’t know a time-server use the pool time servers.

server 192.168.1.1          #Time server on local network or VPN connected
server 0.nl.pool.ntp.org    #Time server from pool.

When the ntp.conf file is ready the NTP service can be started,however when the time difference between the system clock and the internet time is to large, the NTP daemon will not adjust the time, so first synchronize the time to a NTP server and then start the NTP daemon :

ntpdate ntp0.nl.uu.net
service ntpd start.

The correct operation of the ntp server and the availability of the time servers can be checked with the ntpq -p command. The command gives the following response:

#ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
-induna.saix.net 193.67.79.202    2 u  164 1024  377  201.912   -6.414   0.621
+ns1.telecom.lt  212.59.3.3       2 u   52 1024  377   63.280    0.852   0.603
-fritz.box       194.109.22.18    3 u  342 1024  377    0.942    2.269   0.470
 192.168.73.7    192.53.103.108   2 u  282 1024  377   45.278   -1.156   0.396
 192.168.177.12  .STEP.          16 u    - 1024    0    0.000    0.000   0.000
*ptbtime1.ptb.de .PTB.            1 u  245 1024  377   52.905   -0.709   0.651
+auth1.xs4all.nl 193.79.237.14    2 u  376 1024  377   27.648    1.313   0.101
 LOCAL(0)        .LOCL.          10 l   42   64  377    0.000    0.000   0.001
xnut.rsuitb.ru   6.146.162.110    3 u  105 1024  377   69.961   83.107  24.876

Check the ntp time to make sure the server is synchronized with the ntptime command.

#ntptime
ntp_gettime() returns code 0 (OK)
  time d445444f.45e74000  Wed, Nov  7 2012 21:34:23.273, (.273060),
  maximum error 304507 us, estimated error 460 us
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset 90.000 us, frequency 145.151 ppm, interval 1 s,
  maximum error 304507 us, estimated error 460 us,
  status 0x1 (PLL),
  time constant 6, precision 1.000 us, tolerance 512 ppm,

The command shows ntp_gettime which returns OK and ntp_adjtime which returns ok.
Sometimes it is useful to monitor the NTP daemon. The following command can be useful to do this.

while true; do clear; ntpq -p; ntptime; sleep 1; done

This can be stopped by <control> c