Bash – Launch a background process and check when it ends

bash

How can I launch a process in background and check when it ends within a bash script?
My idea is a script like this:

launch backgroundprocess &
while [ Process is running ];do
   echo "PROCESS IS RUNNING\r"
done;

echo "PROCESS TERMINATED"

Best Answer

The key is the "wait" command:

#!/bin/bash

/my/process &
/another/process &
wait
echo "All processes done!"