Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Control the Network Time Server settings from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Control the Network Time Server settings from the command line
Authored by: rsnyder on Apr 07, '08 10:25:57AM

From the command line you can use the systemsetup command to interact with the time server settings. This can particularly users who are managing headless OS X boxes that experience the time drift issue.

One of the downsides of the GUI System Preferences tools is that in the case of updating the system time requires that you open the Date and Time system preferences pane to trigger an update.

I manage several dozen OS X server boxes, and this issue causes my servers to drift out of sync, leading to all sorts of problems.

But creating a script that uses the network time server functions of the systemsetup command, combined with crontab, to force resyncing on a regular basis.

The available commands are:

Viewing or Changing Network Time Server Usage

To see if a network time server is being used:
$ sudo systemsetup -getusingnetworktime

To enable or disable use of a network time server:
$ sudo systemsetup -setusingnetworktime (on|off)

To view the current network time server:
$ sudo systemsetup -getnetworktimeserver

To specify a network time server:
$ sudo systemsetup -setnetworktimeserver timeserver

While this is a rather ham-handed way of doing things, creating a script that turns the use of the network time server off and then back on again will force the system to synchronize its clock with your desired time server. Create a cron job that runs the script as root once a day, or once a week, and you should no longer have problems with drifting time.

[ Reply to This | # ]