Skip to content

Instantly share code, notes, and snippets.

@adis-io
Created November 28, 2016 05:46
Show Gist options
  • Save adis-io/9aa62bef2832c4bebb6591af2d5813e1 to your computer and use it in GitHub Desktop.
Save adis-io/9aa62bef2832c4bebb6591af2d5813e1 to your computer and use it in GitHub Desktop.
#! /bin/bash
items="1 2 3 4 5 6"
pids=""
for item in $items; do
sleep $item &
pids+="$! "
done
for pid in $pids; do
wait $pid
if [ $? -eq 0 ]; then
echo "SUCCESS - Job $pid exited with a status of $?"
else
echo "FAILED - Job $pid exited with a status of $?"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment