[ntp:questions] ntpdate

Scott Haneda talklists at newgeo.com
Wed Jun 10 21:27:06 UTC 2009


On Jun 9, 2009, at 8:30 PM, Danny Mayer wrote:
> Scott Haneda wrote:
>> Hello, I am not sure this is the correct list, but it is the  
>> closest I
>> could find.  I hope there is someone here who can at least point me  
>> in
>> the correct direction.
>>
>> I am having trouble with `ntpdate` on OS X, using version
>>
>> $ntpdate -v
>>  1 Jun 20:03:47 ntpdate[1008]: ntpdate 4.2.2 at 1.1532-o Thu Feb  5
>> 07:51:24 UTC 2009 (1)
>>
>> Is this the correct place?
>> Thanks
>
> Yes, but what's the question?


I am only looking for the basics of keeping my system clock in sync on  
OS X 10.5.  On OS X 10.5 the clock will drift badly on a machine that  
is not logged in.  If you log in, it is less of a problem, but the  
date and time parts of OS X do not check into the time servers nearly  
often enough.  An idle machine is usually fine, but certain types of  
applications can stall the OS, and in turn, stall the clock.  For a  
server, this makes log files a royal pain to deal with timestamps.

I run, on a schedule, with launchd, which can be thought of as a cron  
like scheduler for OS X, once an hour, and also, when the machine  
boots.  Launchd can be told to run on load as well.  I sleep the  
script long enough for all interfaces to come up.

Here is my command:
	/usr/sbin/ntpdate -u

This works fine, all the time, sans one exception.  If the machine has  
a kernel panic, or some form of more serious crash, it will come up  
with the date and time set to 1969, which I believe is Apple's epoch  
( December 31, 1969, at 4 pm PST )

This happens on all OS X machines, I have only tested on 10.4 and  
10.5, and only on PPC hardware, I do not have a way to get the date  
and time to fall into 1969 on an Intel machine.

When this happens, I can see in my syslog, that /usr/sbin/ntpdate -u  
is called, on the normal schedule, but the date and time is never  
synced.  At first I thought I needed to tell it I will allow ntpdate  
to jump huge ranges of times, but I do not believe that to be the case.

Syslog tells me, as a normal working result:
Jun 10 00:40:48 moses com.domain.ntpdate[78719]: 10 Jun 00:40:48  
ntpdate[78741]: adjust time server 17.151.16.21 offset -0.070716 sec

* That is actually the output of launchd to syslog, lunachd just  
passes the output of a command into syslog.

Here is a failure line, after I had a kernel panic.
Dec 31 16:00:54 host-domain-com com.apple.launchd[1] >>  
(com.domain.ntpdate[50]): Exited with exit code: 1

What is exit code 1 of ntpdate?

Interestingly, all I have to do to solve this, is ssh in, and run /usr/ 
sbin/ntpdate -u, at which point, the lunachd scheduler will have no  
issue with it on the next run.  I can not find any way to do this  
without user intervention.  Being on a email server, I get a lot of  
calls that their emails are dated wrong.

I first confirmed with the launchd mailing list that this was not an  
issue with launchd, and they felt certain it was not. This I am not  
sure sure of, since if I can call the same command by hand, and  
lunachd is doing the exact same thing, it makes it confusing as to  
where the issue is.

Any more data, would help a lot, if it turns out to not be a ntpdate  
issue, I need something to go back with to the launchd list.

Thank you
-- 
Scott * If you contact me off list replace talklists@ with scott@ *




More information about the questions mailing list