Mailinglist Archive: opensuse (2912 mails)

< Previous Next >
Re: [SLE] Time synch problem
  • From: "Carlos E. R." <robin1.listas@xxxxxxxxxx>
  • Date: Tue, 22 Feb 2005 21:25:30 +0100 (CET)
  • Message-id: <Pine.LNX.4.58.0502222102000.7902@xxxxxxxxxxxxxxxx>

The Tuesday 2005-02-22 at 07:01 -0800, Randall R Schulz wrote:

> Hi, Carlos,
>
> It seems you have some time on your hands...

I had a free hour, and wanted to exercise my neurones :-)


> > When the connection goes up, /etc/ppp/poll.tcpip does this:
> >
> > while true ; do
> > set -- $(/sbin/runlevel)
> > test -e /etc/init.d/rc${2}.d/S*xntpd && break
> > test -x /usr/sbin/ntpdate || break
> > checkproc /usr/sbin/xntpd &> /dev/null && break
> > /usr/sbin/rcxntpd ntptimeset
> > break
> > done
>
> It seems to me there's nothing to keep this loop from saturating the CPU
> if none of the conditions that allow it to terminate are met. Perhaps a
> "sleep" following the invocation of rcxntpd?


Well, for one, it is written by SuSE, so I shouldn't worry too much ;-)
For another, I have it dissabled completely, I use my own ip-up.local
instead.

Wouldn't the last line (break) break in any case?

I think it is not really a loop, only a "cute" way of chaining
if/then/else sentences.

Let me see... the "set" line I don't understand, but the runlevel comand
"prints the previous and current system runlevel on its standard output,
separated by a single space. If there is no previous system runlevel, the
letter N will be printed instead". Ah, it sets the first parameter to "N"
and the second ${2} to "5" in my system.

Then the test line "breaks" out of the loop if there is a symlink in
runlevel 5 (from the previous line) to xntpd, meaning that the xntpd
daemon is defined to run - in that case, we must not attempt to set the
time here.

The next line check to see if exists '/usr/sbin/xntpd' and is executable,
and breaks otherwise.

The checkproc line checks if /usr/sbin/xntpd is running, and breaks if it
is.

The next line executes "rcxntpd ntptimeset", setting the time.

And the next, breaks out, in any case.

No, the loop executes only once, it is not a loop. Clever... I must save
this example for myself ;-)



The poll.tcpip script is complex, it has "trap" sentences, for instance:

trap 'echo' SIGHUP SIGINT SIGQUIT
trap 'rm -f /var/run/poll.lock; exit 1' SIGTRAP SIGBUS SIGKILL SIGPIPE SIGTERM
trap 'rm -f /var/run/poll.lock; exit 0' EXIT




> This brings up another thing I just learned recently:
...

> Pause for NUMBER seconds. SUFFIX may be 's' for seconds
> (the default), 'm' for minutes, 'h' for hours or 'd' for
> days. Unlike most implementations that require NUMBER be
> an integer, here NUMBER may be an arbitrary floating point
> number.
>
>
>
> Note in particular the last sentence.

Yes, I use it fairly often. I didn't remember about the floating point,
though. Funny, and interesting :-)

--
Cheers,
Carlos Robinson


< Previous Next >
Follow Ups