I have a few scripts: collection.sh start.sh script1.sh and script2.sh. I have these set up to run at boot time so that:

  • collection.sh calls start.sh
  • start.sh calls both script?.sh

collection is set up by the following:

$ cp collection.sh /etc/init.d/
$ update-rc.d collection.sh defaults 99

If I run the collection.sh manually (i.e. $ . /etc/init.d/collection.sh) then everything works as expected, but if I reboot or do a full shutdown and start the computer then collection.sh runs but start.sh never runs.

To clarify, here is an example of what each script looks like:

  • collection.sh:

    . /path/to/start.sh &
  • start.sh:

    ./script1.sh &
    ./script2.sh &
  • script1.sh/script2.sh:

    while :
        #does some stuff here
        #yes this is an infinite loop

I have print statements that have confirmed that collection.sh starts (twice actually) and start.sh never starts.

I have also confirmed, using ps aux | grep collection.sh that collection.sh does complete.

  • What happens if you execute the script /etc/init.d/collection.sh instead of sourcing it . /etc/init.d/collection.sh? – techraf Feb 14 '16 at 22:50

You may have problem with paths.

change PATH in start.sh or use full paths in start.sh to start script[12].sh

You don't mention which distribution you're using (each one is slightly different) -- a sledgehammer approach is sometimes putting lines in /etc/rc.local.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.