When I have set Mac OS X to set it's date and time automatically, how often is this really done? And is there a way I can force an update?
5 Answers
Update
Since OS X 10.14 (Mojave) ntpdate command has been removed - use sntp instead:
sudo sntp -sS time.apple.com
Original answer
For older versions of OX X (pre 10.14), the original answer below is still applicable.
To manually update time with NTP, use ntpdate from a shell:
ntpdate -vu (server or IP address)
e.g.,
sudo ntpdate -vu time.apple.com
References:
- Archived copy of
ntpdate(8)(for “Mac OS X version 10.9”) - More current (but still obsolete) copy
ntpd- Network Time Protocol (NTP) daemon- Sntp User’s Manual
ntpdate options:
-v
Be verbose. This option will cause
ntpdate’s version identification string to be logged.-u
Direct
ntpdateto use an unprivileged port for outgoing packets. This is most useful when behind a firewall that blocks incoming traffic to privileged ports, and you want to synchronise with hosts beyond the firewall. Note that the-doption always uses unprivileged ports.-q
Query only – don't set the clock.
Disclaimer: The functionality of this program is now available in the
ntpdprogram.
See the-qcommand line option in thentpd- Network Time Protocol (NTP) daemon page.
After a suitable period of mourning, thentpdateprogram is to be retired from this distribution.
- 491
- 4
- 5
- 831
- 1
- 6
- 2
-
6`sudo: ntpdate: command not found` on macOS 10.14 Use `sudo sntp -sS time.apple.com` instead – Vinnie James Nov 10 '18 at 17:31
NTPd (used by Mac OSX) will sync at the speed it thinks is more appropriate - that depends on your clock skew. It will be more frequent when you first turn it on / connect to the net and then will connect at longer intervals when it has stabilized your clock enough.
It does not only sync your current time and date, but also sync the actual clock speed. That means that after some time that you have enabled it (and are connected to the internet) your clock will be very precise even if you stay disconnected from the 'net for long times.
If you want the gory details, head on to wikipedia and to the NTP site.
- 535
- 5
- 17
-
6One method to force an update is to turn the automatic synchronization off and then back on. – Chealion Jun 23 '10 at 13:57
-
-
1@Pacerier Try it. Toggle the checkbox at `System Preferences > Date & Time > Date & Time > Set date and time automatically`. – GDP2 Mar 19 '19 at 19:33
-
I have toggled that checkbox and it doesn't accomplish a sync, I'm still 30 seconds or so off. – Ken Williams Nov 25 '19 at 18:21
Checking/Unchecking the set timezone automatically on the date & time settings tab didn't help me.
I ended up using sntp client from the commandline
As you can see below, my time is ~30 seconds too fast.
❯ sntp pool.ntp.org
sntp 4.2.8p10@1.3728-o Tue Mar 21 14:36:42 UTC 2017 (136.200.1~2533)
kod_init_kod_db(): Cannot open KoD db file /var/db/ntp-kod: No such file or directory
2018-10-30 10:03:35.514209 (-0300) -27.660871 +/- 18.459649 pool.ntp.org 197.84.150.123 s2 no-leap
I slewed my clock as root
sh-3.2# sntp -S pool.ntp.org
sntp 4.2.8p10@1.3728-o Tue Mar 21 14:36:42 UTC 2017 (136.200.1~2533)
kod_init_kod_db(): Cannot open KoD db file /var/db/ntp-kod: No such file or directory
2018-10-30 10:06:26.214299 (-0300) -27.574985 +/- 18.423331 pool.ntp.org 41.231.53.4 s2 no-leap
A further sntp reveals that synchronization has been achieved
sh-3.2# sntp -S pool.ntp.org
sntp 4.2.8p10@1.3728-o Tue Mar 21 14:36:42 UTC 2017 (136.200.1~2533)
kod_init_kod_db(): Cannot open KoD db file /var/db/ntp-kod: No such file or directory
2018-10-30 10:06:02.523568 (-0300) -0.032662 +/- 0.061844 pool.ntp.org 41.231.53.4 s2 no-leap
- 131
- 3
The network time daemon (ntpd) logs activity to /var/log/system.log. You can see recent activity with grep:
$ grep ntpd /var/log/system.log | grep "time reset"
Jun 18 22:28:56 mymac ntpd[28]: time reset -0.301952 s
Jun 19 10:37:26 mymac ntpd[28]: time reset -1.443661 s
Jun 20 09:46:07 mymac ntpd[28]: time reset -3.529638 s
Jun 21 09:57:43 mymac ntpd[28]: time reset -3.293325 s
Jun 21 22:25:11 mymac ntpd[28]: time reset -0.539650 s
Jun 21 22:43:12 mymac ntpd[28]: time reset +0.142553 s
Jun 22 09:24:23 mymac ntpd[28]: time reset -1.844003 s
Jun 22 09:41:59 mymac ntpd[28]: time reset -0.156320 s
Jun 23 09:06:00 mymac ntpd[28]: time reset -1.880272 s
Read the ntp.conf man page (man ntp.conf) for details on further configuring ntpd including how much info is logged and (I assume) frequency of updates.
- 27,333
- 17
- 78
- 105
-
Interesting. Will have to run this command once in a while to see if something is happening. – Svish Jun 23 '10 at 15:14
Also if way out of date, turn off time server, set date manually first. Then when you turn on the NTP it will sync. Otherwise it just ignores what the time clock says. 1944 and 1970 years will not sync the clock.
- 31
- 1