Re: A clean way to introduce delay between scripts in /etc/init.d?
One thing you can do is check every few seconds to see if the script has
You could, for example, have bind9 remove a blocking file when it is
starting, and recreate it when it is done (or vice versa). Have your
later script check for the existence of the file when it starts.
It's also a good thing to put a timeout into the loop, so that you don't
I have a script snippet that does something similar. It checks to see if
pump has assigned an IP address in the wanted subnet, and then uses that
address if it is assigned (or times out after 8 attempts).
In this case, you can use the value of $emsg to decide what to do after
this loop (I just print it).
The question for success here is whether the read gets enough words to
fill 'num' with the
last octet of the IP address from 'ifconfig -a'
# the network address:
dmsg="waiting for dhcp"
for i in 1 2 3 4 5 6 7 8 splat ; do
read a b c d num remaining <<-EOF
` ifconfig -a | grep inet | grep -F $NETIP | tr . ' ' `
if [ -n "$num" ] ; then
[[ -z "$emsg" ]] && emsg="-n" || emsg=" done! "
echo -n "$dmsg "
dmsg=" ... "
[ "splat" = "$i" ] || sleep 5
echo $emsg "<$num>"
LEE, Yui-wah (Clement) wrote:
What is a clean way to introduce a delay between the
scripts in /etc/init.d ?
I saw a problem that /etc/rc2.d/S27bind9 started before
/etc/rc2.d/S25ifplugd actually completed all the tasks
Specifically, ifplugd, with the help of resolvconf,
would generate the file /var/run/bind/named.options,
which would be used by bind9. Unfortunately by the
time bind9 ran, the file was not yet generated.
I could force a delay between the two scripts by
introducing another script (run at S26) that does
nothing but sleep for a fixed time (30 seconds). That
seemed to work around the problem. But I wonder if
there is a cleaner solution.
Ideally, the delay should not be fixed but dynamic.
That is, a later script can have some means to know for
sure that an earlier script has completed all the tasks
Stephen Samuel +1(778)861-7641 email@example.com
Powerful committed communication. Transformation touching
the jewel within each person and bringing it to light.