Shell/Bash: start multiple bash processes and wait for all to complete Example

By

Shell/Bash Example: This is the "start multiple bash processes and wait for all to complete" Example. compiled from many sources on the internet by SimpleTutorials.org

start multiple bash processes and wait for all to complete

#!/bin/bash

FAIL=0

echo "starting"

./sleeper 2 0 &
./sleeper 2 1 &
./sleeper 3 0 &
./sleeper 2 0 &

for job in `jobs -p`
do
echo $job
    wait $job || let "FAIL+=1"
done

echo $FAIL

if [ "$FAIL" == "0" ];
then
echo "YAY!"
else
echo "FAIL! ($FAIL)"
fi



* Summary: This "start multiple bash processes and wait for all to complete" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!

Others