Accurate system time is essential for macOS operations, ranging from TLS certificate verification and Kerberos authentication to Git commit ordering and cloud backup synchronization. While macOS automatically synchronises its clock via background daemons like timed, network administrators and power users frequently need to diagnose time discrepancies, verify NTP server latency, or manually correct hardware clock drift.
In macOS, Apple provides the native sntp (Simple Network Time Protocol) utility. Unlike generic ping utilities, sntp establishes a lightweight UDP query on port 123 to measure network round-trip delays, quantify clock stratum levels, and adjust the local system clock.
Understanding the sntp Utility
The sntp tool serves dual functions in macOS:
- Diagnostic Mode (Query Only): Queries designated remote NTP servers without altering the local system clock. It outputs precise clock offset (drift), stratum level, precision, and round-trip delay.
- Correction Mode (Clock Setting): Requires root privileges via
sudoto set or step the local system clock to match the upstream reference clock.
Core Command Flags and Options
The table below outlines the primary flags used with sntp on macOS:
| Flag | Function | Usage Context |
|---|---|---|
-d |
Debug Mode | Displays full verbose output including packet headers, stratum, dispersion, and leap indicators. |
-s |
Step/Set Clock | Immediately steps the system clock to the remote server time (requires sudo). |
-S |
Slew Clock | Gradually slews the clock by adjusting ticking frequency rather than jumping time abruptly. |
-K <file> |
Kod (Kiss-o’-Death) File | Specifies a tracking file for NTP rate-limiting compliance. |
-t <seconds> |
Timeout | Sets the socket read timeout in seconds (default is 15 seconds). |
Querying NTP Servers to Measure Clock Drift
To inspect your current clock drift relative to Apple’s default time servers without altering system state, execute the following command in Terminal:
sntp time.apple.com
The terminal will return a formatted timestamp string along with the measured offset:
+0.001824 +/- 0.015243 time.apple.com 17.253.52.125
In this output:
+0.001824indicates that your local system clock is approximately 1.8 milliseconds ahead of the reference server.+/- 0.015243represents the estimated error margin (dispersion plus round-trip network latency).
Performing Verbose NTP Diagnostics
When troubleshooting network firewalls or enterprise time synchronization failures, pass the -d flag to inspect complete packet header data:
sntp -d pool.ntp.org
This command outputs packet exchange parameters:
sntp [email protected]
Connecting to pool.ntp.org (UDP port 123)...
Stratum: 2
Precision: -24
Root Delay: 0.0215
Root Dispersion: 0.0142
Reference ID: 192.168.1.1
Originate Timestamp: 3938192842.12849
Receive Timestamp: 3938192842.14920
Transmit Timestamp: 3938192842.14922
Destination Timestamp: 3938192842.17011
Offset: -0.000412 secs
Forcing System Time Synchronisation
If your system clock has drifted significantly (for example, following battery replacement or hypervisor snapshot resumption), you can force an immediate clock synchronisation:
- Open Terminal from Applications > Utilities.
- Execute
sntpwith the-sflag using administrative privileges:sudo sntp -s time.apple.com - Enter your macOS user password when prompted.
- To confirm the active time daemon status, query macOS’s background time synchronisation service:
sudo sudo killall timedmacOS will immediately restart the
timeddaemon and re-anchor system time against your configured System Settings time server.
Frequently Asked Questions
Why does sntp return “Operation not permitted” when setting time?
Setting or slewing the system clock modifies kernel hardware timers, which requires superuser privileges. Always prepend sudo when using the -s or -S flags.
What is the difference between stepping (-s) and slewing (-S)?
Stepping jumps the clock immediately to the exact second, which is suitable for large errors but can disrupt cron jobs or database logs. Slewing alters the speed of system clock ticks slightly until it catches up, preventing timestamp reversal.