What's the easiest way to make Busybox keep correct time?

K.S. skyscanner at gmx.ca
Mon Sep 1 10:49:17 UTC 2014


Harald Becker <ralda <at> gmx.de> writes:

> 
> Hi !
> 
> Only as mail, not on ML.
> 
> May be I can help a bit ...
> 
>  >> start() {
> >> 	echo -n "Starting ntpd: "
> >> 	/usr/sbin/ntpd -p north-america.pool.ntp.org && \
> >> 	echo "OK" || { echo "failed"; exit 1 }
> >> }
> 
> I can't see why this shall not work, except if you have put a space 
> after that backslash (\), which would break the line continuation (same 
> as just putting all on one long line).

When I make that change, though, it doesn't work.  Even if I take out the \
and combine the two lines it doesn't work.  I have no clue why that would be.

> That && and || works as follows, when the program (here ntpd daemon 
> start) succeeds with no failure the command after && is executed ("echo 
> OK"), else the command after || is executed (echo "failed", then exit 
> script).

I understand the reasoning, I'm just saying that twice now I've tried to
make that change and it didn't work.  I actually think it messes up ssh in
some way too, because when I've tried to make that change and then
subsequently tried to ssh in, it takes several seconds to get the command
prompt, whereas normally it comes up almost instantaneously (I was almost
afraid I'd somehow bricked the system at first).

> > No idea why your change didn't seem to work but then it occurred to me that
> > it really makes no difference because in this situation nobody's ever going
> > to see that exit code anyway.
> 
> Isaacs change is, to be just formal correct.

Well, I had nothing to do with building this system so I have no idea why
the formal correct version doesn't seem to want to work.

> start-stop-daemon is a command to handle start/stop of such long lived 
> (so called daemon) processes. It may also be an applet of Busybox (but 
> not all do include this). For it's usage see manpage (e.g. Google 
> "start-stop-daemon manpage").
> 
> What Isaac wanted to say is, this start-stop-daemon checks some error 
> conditions, like accidental duplicate invocation and other well known 
> problems. It thereafter give hints about the problem or the possibility 
> to handle those problems in your script. This may make things more 
> stable and fit the formal definition, but is not required to get things 
> going (would hit you only if go to distribute your system to others).

Very interesting, and thank you, but it's not something I am particularly
concerned about at the moment, in part because if this start-stop-daemon is
optional to a particular build then chances are it's not even included in
this one.

If nothing else, this has been educational.  I'm still hopeful that the
company that makes this device might have a better solution that will work
without any problems.



More information about the busybox mailing list