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
- 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
- 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.
Here's an example of an ntpq -p command showing the time is not in synch, look at the size of the offset :-
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
- ntpd: sendto(18.104.22.168) (fd=-1): Bad file descriptor
- ntpd: sendto(22.214.171.124) (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
- /etc/init.d/ntp stop
- killall ntpd
- /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
- ntpd -q
- on older machines you can use
- ntpdate <host>
Once the time is in synch it will be best to set the hardware clock with the following command :-Show Plain Text
- hwclock --systohc [--utc]