Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. – user495470 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
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/ 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 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/

share|improve this answer

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

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 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.