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

Harald Becker ralda at gmx.de
Mon Sep 1 09:05:53 UTC 2014


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).

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).

> 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.

>> And a lot of people use start-stop-daemon, probably because it can handle
>> various corner cases better.

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).

--
Harald


More information about the busybox mailing list