My quick NTP notes

These are just some quick notes on the Network Time Protocol (NTP) server for my reference and will get updated when time permits.

To install simply run :-

Show Plain Text
Text code
  1. apt-get install ntp

You can edit then edit the /etc/ntp.conf file adding any local servers or options for the process to start up with.

To check the ntpd server is synchronizing correctly run :-

Show Plain Text
Text code
  1. ntpq -p [<hostname>]

You should get something like the following table where you want the offset to be as small as possible. If the offset value is greater than 1024 it is highly likely that the clock is not being set, drifting and doing its own thing. This can happen with network faults and if your PC is thrashing.

remoterefidsttwhenpollreachdelayoffsetjitter
gen2.ihug.co.nz130.217.76.342u56439.2392.0131.101
ns2.tpnet.co.nz131.203.16.62u464322.021-17.9140.054
jaffa.inode.co.nz131.203.16.102u66437.0351.2274.853

Here's an example of an ntpq -p command showing the time is not in synch, look at the size of the offset :-

remoterefidsttwhenpollreachdelayoffsetjitter
gen2.ihug.co.nz130.217.76.342u57643777.108-78164787510.0
ns2.tpnet.co.nz131.203.16.62u606437321.647-66152278586.4
ipaudit.tpnet.co.nz131.203.16.62u616437721.939-78164587458.9

If the time does not synch you can check the /var/log/syslog for any error entries. For example if you getting bad file descriptor errors like the following :-

Show Plain Text
Text code
  1. ntpd[8210]: sendto(218.185.224.8) (fd=-1): Bad file descriptor
  2. ntpd[8210]: sendto(203.109.252.7) (fd=-1): Bad file descriptor

The most likely cause is that you are running too many NTP daemons which are clashing. Stop all daemons and try and start the NTP again, as follows :-

Show Plain Text
Text code
  1. /etc/init.d/ntp stop
  2. killall ntpd
  3. /etc/init.d/ntp start

If you have a synchronization problem with the offset to your local time being to great i.e > 1024 seconds, you can manually force NTP to synch with :-

Show Plain Text
Text code
  1. ntpd -q
  2. on older machines you can use
  3. ntpdate <host>

Once the time is in synch it will be best to set the hardware clock with the following command :-

Show Plain Text
Text code
  1. hwclock --systohc [--utc]
Filed under: Linux  Tags: Debian, Ubuntu

0 Responses to “My quick NTP notes”

Sorry, comments have been closed for this post.