Take the 2-minute tour ×

I need to check programmatically whether Set Date and Time automatically is checked or not on a Mac System Preferences.

I didn't find any .plist file that contained this information, can anybody tell me where I can find this information?

share|improve this question
I suspect that there may be a better programmer-oriented answer to this question. Could I recommend that you flag this post and request it to be migrated to StackOverflow? –  Jason Salaz Dec 4 '11 at 23:44
@JasonSalaz This would be off-topic at Stack Overflow. –  ؘؘؘؘ Dec 5 '11 at 4:49
Programming/API/SDK questions are not off topic at Stack Overflow. "I need to check programmatically" says the OP. –  Jason Salaz Dec 5 '11 at 10:08
I suppose the question I would ask first is... What method you want to use to hold of the information, and in what format. I can think of at least two ways of getting the info using AppleScript, one using the file and plist read functions, and the second using the System Preferences AppleScript interface itself. The second method could also provide a method to set the option if it is not set, however I do not believe that is possible if the security on the pane is activated. It shouldn't take long to rig up a script to do it either. –  Stu Wilson Jan 11 '12 at 23:20
I'm very tempted to edit this to make it more on-scope, but much of the comments would then seem out of place. Perhaps I can answer it to help clarify what is on-topic here and what is not. –  bmike Jul 2 '12 at 14:57

3 Answers 3

up vote 1 down vote accepted

The end result of the "Set Date and Time Automatically" checkbox is that the ntpd daemon gets started by launchd.

So you could check for the presence of the file /var/run/ntpd.pid or presumably check if ntpd is running as a process. This is all good and fine for the site, but your second part to the question on how to programmatically retrieve this status is basically off-topic here.

We do allow limited AppleScript, Automator, and shell scripting programming questions. The full scope of developer questions (especially with new OSX restrictions such as sandboxing) or code level Q&A on how to program are best asked on http://stackoverflow.com/ rather than here.

With that out of the way - here's the back story about why this actually a fairly complicated question. Launchd is responsible for starting and stopping ntpd time keeping daemon when you toggle that switch and rather than load or unload the configuration file for that "job", the tool instead has an internal override plist file that has a true/false status for certain jobs to be disabled even though they should normally run. When you toggle the System Preference checkbox in Date & Time, this file changes Disabled key value at the end of the file to be or when automatic timekeeping is off or on (respectively).:

From /private/var/db/launchd.db/com.apple.launchd/overrides.plist

share|improve this answer

I found this discussion on the discussions fora of Apple. It describes how to get the time in the menu bar, but with it also how to get to the plist programmaticly.

share|improve this answer
Can you please add more information on your answer? And add the website as a source? –  Loïc Wolff Oct 5 '11 at 14:08
sure, no problem. –  Michiel Oct 5 '11 at 14:17
Thanks for your reply,but com.apple.GlobalPreferences.plist doesnot exists on my box in any Library/Preferences locations –  Akbar Oct 7 '11 at 6:55
That's probably because the file is called /Library/Preferences/.GlobalPreferences.plist –  patrix Nov 4 '11 at 17:46

I don't know of a purely programmatic way of getting it, but the systemsetup command can do it:

$ systemsetup -getusingnetworktime
Network Time: On
share|improve this answer
This will set the NTP server for your Mac "systemsetup -setnetworktimeserver <ntpserver>" and "systemsetup -getnetworktimeserver" to get the current time server. –  grantc Apr 3 '13 at 6:33

Your Answer


