A computer's time and date settings affect some surprisingly big issues and are often-overlooked culprits to problems. For instance, time is tied to several facets of the underlying system's security and its ability to transmit data securely. An incorrect time or date will even prevent a node from successfully authenticating on a network since Kerberos (among other related technologies) rely heavily on accurate time for its time-stamps.
Below are several commands that you could execute remotely in OS X — either from Terminal or scripted — to ensure a machine's time is always in sync.
Set network time server
- Command: systemsetup -setnetworktimeserver time.apple.com
- Result: Sets the network time server to any domain or IP-based address.
Set network time server service on/off
- Command: systemsetup -setusingnetworktime on
- Result: Turns the network time server service on or off.
- Command: systemsetup -settimezone timezone
- Result: Sets the timezone based on argument. Using the -listtimezones argument will list country codes to use in setting the correct timezone to match your needs.
Set current date
- Command: systemsetup -setdate mm:dd:yy
- Result: Adjusts the current date as specified manually.
Set current time
- Command: systemsetup -settime hh:mm:ss
- Result: Adjusts the current time as specified manually.
What to watch with these settings
When managing time or date settings, there are a couple of things to watch.
- Double-check your command before signing out, as it could lead to access issues.
- You cannot run network time service and manage the time/date manually at the same time — one has to give. I typically manage Macs by setting them to a network time server, and this works for 99% of them. However, for the stubborn ones, I will usually turn off the network time service first, and then manually set the date/time correctly. Bonus: This command may also be run via SSH for secure, off-site management.
Join the discussion
Did I miss something? Do you have a better way to manage this feature? Sounds off in the comments. I'd love to hear from you.
- Pro tip: Manage Wi-Fi with Terminal commands on OS X (TechRepublic)
- Top 5 apps that will make OS X sysadmins' lives better (TechRepublic)
- Install command line developer tools in OS X (CNET)
- How to look up Terminal commands for OS X (CNET)
Jesus Vigo is a Network Administrator by day and owner of Mac|Jesus, LLC, specializing in Mac and Windows integration and providing solutions to small- and medium-size businesses. He brings 19 years of experience and multiple certifications from several vendors, including Apple and CompTIA.