| You can use the command You can also retrieve the PID of the last command with In your case, something like this: command1 & #run command1 in backgroundPID=$! #catch the last PID, here from command1command2 #run command2 while command1 is running in backgroundwait PID #wait for command1, in background, to endcommand3 #execute once command1 ended Following your edit, as you have multiple PIDs and you know them, you can do that: command1 & #run command1 in backgroundPID1=xxxxxPID2=yyyyyPID3=xxyyyPID4=yyxxxcommand2 #run command2 while command1 is running in backgroundwait PID1 PID2 PID3 PID4 #wait for the four processes of command1, in background, to endcommand3 #execute once command1 ended |