Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is it possible in Bash to call a shell script from another shell script but not have the original script wait for the sub-script to complete?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Just fork it with a &. As in, sh /path/to/script/script.sh &

This will print messages from the subscript, but you can replace the & with >/dev/null & and suppress the output.

share|improve this answer
So the original script will continue on and can complete with a 0 exit code regardless of if the called script is still running, correct? What if set -e is invoked, does it make a difference? –  user160910 Jun 18 '13 at 14:59
It doesn't. Once it's forked, it's on its own process and PID. nohup as mentioned by the other answer will also keep the process going through logouts and such. –  Nathan C Jun 18 '13 at 16:12
right after you fork the process, you can "capture" its PID with $!. E.g. mypid=$! . I recommend then using wait $mypid at some point in your script to ensure that the forked process ends before ending the script. –  senorsmile Jun 19 '13 at 3:29

You should use "nohup" to make sure the process / script completes even if your user is logged out:

nohup /my/script.sh &
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.