[ntp:questions] status information after ntpd -q

Charles Swiger cswiger at mac.com
Mon Feb 3 18:29:42 UTC 2014


On Feb 3, 2014, at 2:58 AM, joeri delvoy <boterhoeksken at gmail.com> wrote:
> i would like to use the command "ntpd -q" to synchronize with a server once,
> but i need some feedback from the command about the status.

ntpd was designed and is intended to run all of the time as a daemon,
but you can do what you've asked for by setting explicit logging path like:

# ntpd -q -l /tmp/ntpd.log
# cat /tmp/ntpd.log                                                                                                                                                                                ~
 3 Feb 10:21:01 ntpd[26690]: proto: precision = 1.000 usec
 3 Feb 10:21:01 ntpd[26690]: ntp_io: estimated max descriptors: 256, initial socket boundary: 20
 3 Feb 10:21:01 ntpd[26690]: Listen and drop on 0 v4wildcard UDP 123
 3 Feb 10:21:01 ntpd[26690]: Listen and drop on 1 v6wildcard :: UDP 123
[ ... ]
 3 Feb 10:21:01 ntpd[26690]: DNS time.apple.com ttl 4502
 3 Feb 10:21:01 ntpd[26690]: DNS time.apple.com minpoll 9
 3 Feb 10:21:01 ntpd[26690]: DNS time.apple.com maxpoll 12
[ ... ]
 3 Feb 10:21:05 ntpd[26690]: ntpd: time slew -0.000010 s

> I receive the server name and configuration (like if authentication is to be used, and the according keys) from the user of my program,
> so i need to be able to give instant feedback on the command.
> The minimum feedback i would need is :
> 1.if the authentication is succeeded, and if not what is the cause of it.
> 2.if the server is reachable.
> 3.the server timed out (i don't know if the "ntpd -q" command has an option to specify the timeout?)

You'd need to parse the logs above, or tell the user to take a look for themselves, but sure, that info is available.

Also, note that most folks-- certainly users, but also NTP admins-- never need to use authentication with ntpd.

At least, I've been running stratum-1 or -2 timeservers since the late 80s, and have only
setup auth keys for the purposes of testing things that folks on this list have asked about.

> When i use "ntpq -c as" to get some status, i have noticed that this command only works when the ntp daemon is running.
> As soon as i stop the ntp (with "service ntp stop"), i get the error "ntpq: read: Connection refused".

That's right.

> Furthermore i noticed that the command "timedatectl status" gives me back that the NTP is enabled, even though i stopped the NTP service.

That's probably not right, but that's very likely to be a problem with whatever OS you are running, and not ntpd.  :-)


More information about the questions mailing list