When I execute another script from my main script like so:
#!/bin/bash
if cond1; then
stuff
sleep 10
./script1.sh &
elif cond2; then
more stuff
./script2.sh &
else
echo "foo"
fi
stuff
echo "Hello World"
script1.sh & script2.sh do no seem to exit until I close the main script even though I have issued the exit command inside the script1 & script2. Am I missing something? Any input would be greatly appreciated.
The example should work just fine. I suspect there is something wrong with
script1.shorscript2.sh. Or could it be that you are misinterpreting the shell’s notification of finished jobs?