Skip to content

Instantly share code, notes, and snippets.

@AleixMT
Created October 17, 2019 12:57
Show Gist options
  • Save AleixMT/5072ad85654e81e65f3858c01589b4f8 to your computer and use it in GitHub Desktop.
Save AleixMT/5072ad85654e81e65f3858c01589b4f8 to your computer and use it in GitHub Desktop.
Starts in parallel all the commands passed as arguments
#!/bin/bash
for cmd in "$@"; do {
echo "Process \"$cmd\" started";
$cmd & pid=$!
PID_LIST+=" $pid";
} done
trap "kill $PID_LIST" SIGINT
echo "Parallel processes have started";
wait $PID_LIST
echo
echo "All processes have completed";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment