Discussion:
command line to force check date & time via network time server?
chris thacker
2005-06-27 16:59:10 UTC
Permalink
in the system preferences there is the Date & Time preference for
"Set date & time automatically". Is there a way via the command
line to force this to happen? i did "apropos time" and "apropos
date" but didn't see anything other than manually setting the date.

thanks!

____________
Chris Thacker
Campus Life Services - Information Systems
University of California at San Francisco
[help desk] 415 502-5511
[direct line] 415 514-3373
Nicholas Riley
2005-06-27 17:13:53 UTC
Permalink
Post by chris thacker
in the system preferences there is the Date & Time preference for
"Set date & time automatically". Is there a way via the command
line to force this to happen? i did "apropos time" and "apropos
date" but didn't see anything other than manually setting the date.
% apropos date
[...]
ntpdate(8) - set the date and time via NTP
% sudo ntpdate time.apple.com
27 Jun 12:12:36 ntpdate[28523]: step time server 17.254.0.26 offset -4.178644 sec

is what you use to set the time once. If you have the "set date &
time automatically" (aka ntpd) running, you'll need to kill it first.
--
Nicholas Riley <***@uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
Alex Satrapa
2005-06-28 00:29:13 UTC
Permalink
Post by Nicholas Riley
% sudo ntpdate time.apple.com
27 Jun 12:12:36 ntpdate[28523]: step time server 17.254.0.26 offset -4.178644 sec
It's worth noting that the "set date and time automatically" feature
won't work unless the date and time is close enough already - I think
"close enough" is something like one or two minutes.

Once you use ntpdate to set the time, enabling "Set date and time
automatically" should keep the time to within a second of coordinated
time. This should probably be filed as a bug report, since there's no
indication that the checkbox only means, "keep time in sync
automatically" rather than "just set the time already!"

Alex
William H. Magill
2005-06-28 01:42:57 UTC
Permalink
Post by Alex Satrapa
Post by Nicholas Riley
% sudo ntpdate time.apple.com
27 Jun 12:12:36 ntpdate[28523]: step time server 17.254.0.26
offset -4.178644 sec
It's worth noting that the "set date and time automatically"
feature won't work unless the date and time is close enough already
- I think "close enough" is something like one or two minutes.
Once you use ntpdate to set the time, enabling "Set date and time
automatically" should keep the time to within a second of
coordinated time. This should probably be filed as a bug report,
since there's no indication that the checkbox only means, "keep
time in sync automatically" rather than "just set the time already!"
Yes and no ... NTP is actually working correctly, and "as expected"
-- by those of us who are familiar with NTP:)

If you configure to "set date and time automatically," and then
reboot, the system boot sequence will bring any time into synch
correctly and as expected by everyone.

But you are correct, the new Preference panel is one of those
"gotchas." It is also a change from Panther. In Panther, you had the
ability to actually "set the date and time now" by clicking on a
button. That button is now gone.


T.T.F.N.
William H. Magill
# Beige G3 [Rev A motherboard - 300 MHz 768 Meg] OS X 10.2.8
# Flat-panel iMac (2.1) [800MHz - Super Drive - 768 Meg] OS X 10.3.8
# PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg] Tru64 5.1a
# XP1000 [Alpha 21264-3 (EV6) - 256 meg] FreeBSD 5.3
# XP1000 [Alpha 21264-A (EV 6.7) - 384 meg] FreeBSD 5.3
***@mcgillsociety.org
***@acm.org
***@mac.com
***@gmail.com
Alex Satrapa
2005-06-28 03:22:02 UTC
Permalink
Post by William H. Magill
Yes and no ... NTP is actually working correctly, and "as expected"
-- by those of us who are familiar with NTP:)
If you configure to "set date and time automatically," and then
reboot, the system boot sequence will bring any time into synch
correctly and as expected by everyone.
Well... as a Debian GNU/Linux systems administrator, what is
"expected" by me is that any graphical front end would restart the
NTP service after the configuration has been changed. If not restart,
at least reconfigure

Every time I have to resort to rebooting a Mac, a little piece of me
dies.

Alex
William H. Magill
2005-06-28 13:49:37 UTC
Permalink
On 27 Jun, 2005, at 23:22, Alex Satrapa intoned:On 28 Jun 2005, at
Post by Alex Satrapa
Post by William H. Magill
Yes and no ... NTP is actually working correctly, and "as
expected" -- by those of us who are familiar with NTP:)
If you configure to "set date and time automatically," and then
reboot, the system boot sequence will bring any time into synch
correctly and as expected by everyone.
Well... as a Debian GNU/Linux systems administrator, what is
"expected" by me is that any graphical front end would restart the
NTP service after the configuration has been changed. If not
restart, at least reconfigure
"Best Practices" and I have a very big philosophical problem with
this ...

As is always the case, this is one of those Best Practices situations
where you can "get away with ignoring it" until you get caught on
the .1% of the situations which the BP are intended to protect against.

... If any time "fix" happens to result in setting the clock
BACKWARDS, there can be all kinds of "unanticipated consequences" --
things like databases, log files and the like can be really "confused."

... Similarly, any large forward time gap can really give you trouble
when you have to explain their existence to the Auditors. They have a
nasty habit of wanting to know who erased all the records in the
intervening time period.

Shutting down and rebooting all services when any kind of significant
time change is made is the only way to avoid either situation.
Post by Alex Satrapa
Every time I have to resort to rebooting a Mac, a little piece of
me dies.
People who never reboot Unix based systems also never modify them.
They are called production systems and one would NEVER contemplate
changing the time on a production system on the fly!


T.T.F.N.
William H. Magill
# Beige G3 [Rev A motherboard - 300 MHz 768 Meg] OS X 10.2.8
# Flat-panel iMac (2.1) [800MHz - Super Drive - 768 Meg] OS X 10.3.8
# PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg] Tru64 5.1a
# XP1000 [Alpha 21264-3 (EV6) - 256 meg] FreeBSD 5.3
# XP1000 [Alpha 21264-A (EV 6.7) - 384 meg] FreeBSD 5.3
***@mcgillsociety.org
***@acm.org
***@mac.com
***@gmail.com
Alex Satrapa
2005-06-29 01:50:32 UTC
Permalink
Post by William H. Magill
People who never reboot Unix based systems also never modify them.
They are called production systems and one would NEVER contemplate
changing the time on a production system on the fly!
What about my laptop, which changes networks more regularly than I
change my underwear?

Not all Unix systems are production systems. Not all production
systems are Unix systems. My laptop is a Unix system, and one of my
production databases runs on Windows XP (and ironically enough, it
controls secure access to the facility which the computer resides in).

To me it seems that the Date & Time preferences pane should be
updated to allow the NTP server to be changed on the fly along with
running ntpdate to get the time in sync with coordinated time (the
most friendly option for a Mac OS X machine), or it should be updated
to inform the user that a reboot is required for that change to take
effect (which you argue is the safest option for a Mac OS X Server
machine). At present, there is no feedback at all!

Ideally, the operating system would leave the discipline in the hands
of the administrator. If the option is presented through a GUI, it's
obviously intended to be used by people who aren't aware of the
deeper ramifications of shifting time (or changing NTP servers) in a
mission-critical production system.

Though I wonder why Apple uses NTPd with a minpoll of 12, rather than
just setting up a cron job to run ntpdate once every few hours.

Alex
William H. Magill
2005-06-29 14:01:01 UTC
Permalink
Post by Alex Satrapa
Post by William H. Magill
People who never reboot Unix based systems also never modify them.
They are called production systems and one would NEVER contemplate
changing the time on a production system on the fly!
What about my laptop, which changes networks more regularly than I
change my underwear?
I don't know exactly what scheme Apple uses for Laptops which have
been sleeping.
In theory, the system clock is running even when sleeping so that the
clock drift is minimal, unless the CPU clock is "off."

Changing time zones simply changes the offset, not the actual clock
setting.
Post by Alex Satrapa
To me it seems that the Date & Time preferences pane should be
updated to allow the NTP server to be changed on the fly along with
running ntpdate to get the time in sync with coordinated time (the
most friendly option for a Mac OS X machine), or it should be
updated to inform the user that a reboot is required for that
change to take effect (which you argue is the safest option for a
Mac OS X Server machine). At present, there is no feedback at all!
I don't disagree with you on this one.
Panther did have that ability. It was "removed" in Tiger (or forgotten).
Post by Alex Satrapa
Though I wonder why Apple uses NTPd with a minpoll of 12, rather
than just setting up a cron job to run ntpdate once every few hours.
Mainly because that's what NTP is for. NTP continually checks the
time and compensates for network delays (between you and the
timeserver) the longer it is run. The goal is to keep the local clock
synced with the timeserver with as little a deviation as possible.
Simply running NTPDATE sets the clock to some value (which may or may
not be within seconds of the timeserver).

The primary reason for having "matching clocks" on client machines is
things like Secure ID tags, and other similar challenge, response and
time-based authorization systems.

T.T.F.N.
William H. Magill
# Beige G3 [Rev A motherboard - 300 MHz 768 Meg] OS X 10.2.8
# Flat-panel iMac (2.1) [800MHz - Super Drive - 768 Meg] OS X 10.4.1
# PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg] Tru64 5.1a
# XP1000 [Alpha 21264-3 (EV6) - 256 meg] FreeBSD 5.3
# XP1000 [Alpha 21264-A (EV 6.7) - 384 meg] FreeBSD 5.3
***@mcgillsociety.org
***@acm.org
***@mac.com
***@gmail.com
Creed Erickson
2005-06-29 14:31:40 UTC
Permalink
Post by Alex Satrapa
To me it seems that the Date & Time preferences pane should be
updated to allow the NTP server to be changed on the fly
You can do that today. Simply type in the DNS name or IP address of
your server.
Post by Alex Satrapa
Though I wonder why Apple uses NTPd with a minpoll of 12, rather
than just setting up a cron job to run ntpdate once every few hours.
Because (1) ntpdate will always step the time by whatever the error
delta is where ntpd can slide the time by making "micro adjustments"
at some rate. The later behavior can prevent surprises to certain
types of software. (2) ntpd will, over time, collect stats on the
system's time-keeping and make periodic adjustments to pre-empt
larger clock deltas.
Alex Satrapa
2005-06-30 03:33:43 UTC
Permalink
Post by Creed Erickson
Post by Alex Satrapa
To me it seems that the Date & Time preferences pane should be
updated to allow the NTP server to be changed on the fly
You can do that today. Simply type in the DNS name or IP address of
your server.
That changes the values stored in the /etc/ntp.conf file - it doesn't
restart the NTP server. Try it yourself - use "ntpd -np" to list the
currently used reference clocks, use "cat /etc/ntp.conf" to check
what's in the configuration file.
Post by Creed Erickson
Because ... ntpd can slide the time by making "micro
adjustments" [and] collect stats on the system's time-keeping
Agreed, ntpd will adjust the clock with greater finesse than ntpdate,
regardless of the polling interval involved. I guess the huge polling
interval (36 hours) that Apple uses by default should be okay, given
the stability of modern PC clocks. Note that ntpd on my machine has
consistently rejected the Apple-supplied server for my region (Asia)
since the delay and jitter have been consistently too large for that
server to be useful.

Alex

Continue reading on narkive:
Loading...