From Noah.org
Revision as of 15:27, 8 March 2011 by Root (Talk | contribs) (ntpdate)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The simplest NTP server is OpenNTP. I think it's the only one that will run fresh out of install without additional configuration.

A decent /etc/openntpd/ntpd.conf configuration file will look like this:

# Addresses to listen on (ntpd does not listen by default)
#listen on *
#listen on
#listen on ::1
servers pool.ntp.org


To just query the time use the -1 option. If you don't then the system time will actually be modified.

ntpdate -q pool.ntp.org

step versus adjust

The status messages printed by `ntpdate` can be rather vague and ambiguous. The following two message have very different meanings. Note that one says step and the other says adjust.

 8 Mar 23:12:35 ntpdate[13448]: step time server offset -0.481318 sec
 8 Mar 23:12:42 ntpdate[13451]: adjust time server offset -0.480861 sec

When you adjust the system time you are asking the system to carefully update its clock using a complicated and slow process that spreads the difference out over time so that the jump in time from moment to moment does not exceed some set amount. This helps avoid big skips in time that might confuse some programs or make log files appear to have timestamp gaps or even go backwards in time. This is usually not what most people want when they want to set the system time from the command-line. This is better when used in cron jobs or when consistency in time matters.

When you step the system time you are asking the system to simply set its clock to the new time. It will not do anything fancy. It will simply start using the new time. This is what most people want and expect ntpdate should do by default when used from the command-line. This is not what `ntpdate` does unless you specify the -b option.

ntpdate -b pool.ntp.org