Answers for "start multiple bash processes and wait for all to complete"

2

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
Posted by: Guest on May-04-2020

Code answers related to "start multiple bash processes and wait for all to complete"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language