Saturday, January 3, 2009

Update: Setting your Mac clock to NTP

There are a couple more things I have realized about setting NTP up on Mac that I wanted to share:

Although a restart of the computer should restart ntpd (the Network Time Protocol Daemon), it appeared at first that my computer clock was still not syncing right. The refid = locl means that the computer is using it's own system clock as the reference:


After going back over the ntp.conf file and determining it was fine, I restarted the network time daemon via command line (you can also do this instead of rebooting the whole machine):
$ /sbin/SystemStarter restart "NetworkTime"

Then when I ran the NTP query (ntpq -n -p), I saw that NTP was working. The * indicates the primary peer the computer is synced to, while the + indicates peers that are also contributing to the final time solution.


Apparently on Linux machines, the connection to the ntp time servers is pretty fast (less than a minute usually). On a Mac some reason, this process seems to take longer. The reason it worked after the manual restart of the ntpd is simply because enough time had passed since my reboot that the computer had finally connected to the time servers.


Update 2:

Okay, so I thought I had all the issues figured out, until I got to my boyfriend's place, started up my computer, and it could not connect to the ntp time servers (oy veh!). He had me check my systemlog, where I saw the following message:


Looks like permissions are getting confused somewhere. Next the bf suggested I comment out the section of my ntp.conf that deals with creating the log files (which are not necessary for ntp to work anyway). I commented out the following section:

#driftfile /var/db/ntp.drift
#statsdir /var/log/ntpstats/

#statistics loopstats peerstats clockstats
#filegen loopstats file loopstats type day enable
#filegen peerstats file peerstats type day enable
#filegen clockstats file clockstats type day enable


I then rebooted again, and viola, it instantly recognized the ntp time servers. The weird thing is that sometimes this problem appeared to correct itself after several minutes (thus my first update above). I am not sure what it really going on, and at some point I will have to figure out exactly what I need to set the log file permissions to in order to get everything happy. In the meantime, I am sticking with the ntp.conf with the log file commands commented out.

No comments:

Post a Comment