http://unix.stackexchange.com/questions/124106/shell-script-wait-for-background-commandshell
|
You can use the command You can also retrieve the PID of the last command with In your case, something like this:code command1 & #run command1 in background PID=$! #catch the last PID, here from command1 command2 #run command2 while command1 is running in background wait PID #wait for command1, in background, to end command3 #execute once command1 ended Following your edit, as you have multiple PIDs and you know them, you can do that:ip command1 & #run command1 in background PID1=xxxxx PID2=yyyyy PID3=xxyyy PID4=yyxxx command2 #run command2 while command1 is running in background wait PID1 PID2 PID3 PID4 #wait for the four processes of command1, in background, to end command3 #execute once command1 ended |