Set the System Time in Mac OS X from the Command Line

Jul 4, 2012 - 1 Comment

Clock
The clock in Mac OS X sets itself automatically by default, but if you want to set the precise time or are looking for a command line solution to set system time, you can do so with a tool called ntpdate. Point it either at Apple’s time servers or pool.ntp.org as follows to get the exact time:

sudo ntpdate -u time.apple.com

Enter the admin password when asked, and you’ll soon see something like the following:

4 Jul 14:30:11 ntpdate[28267]: adjust time server 17.151.16.14 offset 0.000336 sec

The offset at the end lets you know how divergent the system clock was with the newly set time. In this example, the system clock was off by a laughably small fraction of a second.

You generally don’t need to do this if you use the “Set date and time automatically” feature within the Date & Time system preferences, though by setting clocks through the command line you could be sure that each machine on a network shows the exact same time.

Topmost image taken from the Flipclock screensaver

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, Mac OS X, Tips & Tricks

One Comment

» Comments RSS Feed

  1. Nigel says:

    Is it possible to automatically set the date/time server through profile manager?

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates