MacOS – How to tell when time has been sync’ed with NTP server in Mac OS X Lion

macosntp

I know that a similar question has been asked at superuser.

But I tried to grep for "time reset" in my /var/log/system.log and I can't find any instance of it. In fact, I even searched in the eight archived copies of system.log (system.log.0.bz2 through system.log.7.bz2). All I found when grep'ing for the word "ntpd" are lines like these:

Feb 20 10:17:16 caspar ntpd[44498]: proto: precision = 1.000 usec
Feb 20 12:27:21 caspar ntpd[44625]: proto: precision = 1.000 usec
Feb 20 18:31:53 caspar ntpd[44625]: bind(28) AF_INET6 > <censored IPv6> flags 0x11 failed: Can't assign requested address
Feb 20 18:31:53 caspar ntpd[44625]: unable to create socket on en0 (7) for <censored IPv6>

Update #1

Following @Raolin's suggestion, I now see lines like this in /tmp/ntpd.log:

21 Feb 19:30:52 ntpd[2328]: DNS time.asia.apple.com. ttl 1900
21 Feb 19:30:52 ntpd[2328]: DNS time.asia.apple.com. minpoll 9
21 Feb 19:30:52 ntpd[2328]: DNS time.asia.apple.com. maxpoll 12
21 Feb 19:30:52 ntpd[2328]: DNS time.asia.apple.com. +iburst
21 Feb 20:02:32 ntpd[2328]: DNS time.asia.apple.com. ttl 4013
21 Feb 21:09:24 ntpd[2328]: DNS time.asia.apple.com. ttl 3507

I'm not sure if the lines containing 'ttl' means it's trying to sync.

Best Answer

I'm not sure if there are any log messages by default—I couldn't find any either.

One possible solution is to just enable logging. You can edit:

/usr/libexec/ntpd-wrapper

And add this (or something similar):

-l /tmp/ntpd.log

To the exec /usr/sbin/ntpd line in the script (the last line). Then kill the ntpd process (it will automatically relaunch) or reboot.

The resulting log looks something like this:

ntpd[10728]: ntpd 4.2.8p6@1.3265 Fri Feb  5 17:38:17 UTC 2016 (124~824): Starting
ntpd[10728]: Command line: /usr/sbin/ntpd -c /private/etc/ntp-restrict.conf -n -g -p /var/run/ntpd.pid -f /var/db/ntp.drift -l /tmp/ntpd.log
ntpd[10728]: proto: precision = 1.000 usec (-20)
ntpd[10728]: proto: fuzz beneath 0.083 usec
ntpd[10728]: Listen and drop on 0 v6wildcard [::]:123
...
ntpd[10728]: drift PPM:0.000 -> -37.418
ntpd[10728]: peer time.asia.apple.com. @ 17.253.66.125
ntpd[10728]: sample offset +0.000000 s @ 17.253.66.125
ntpd[10728]: sample offset -0.000569 s @ 17.253.66.125
ntpd[10728]: sample offset -0.000518 s @ 17.253.66.125