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          #Time server on local network or VPN connected
server    #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 :

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
==============================================================================    2 u  164 1024  377  201.912   -6.414   0.621       2 u   52 1024  377   63.280    0.852   0.603    3 u  342 1024  377    0.942    2.269   0.470   2 u  282 1024  377   45.278   -1.156   0.396  .STEP.          16 u    - 1024    0    0.000    0.000   0.000
* .PTB.            1 u  245 1024  377   52.905   -0.709   0.651    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    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.

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