Skip to content

Instantly share code, notes, and snippets.

@alvin4frnds
Created October 24, 2024 09:33
Show Gist options
  • Save alvin4frnds/41ccf5262bfb5e241ff8a3f5164b08c4 to your computer and use it in GitHub Desktop.
Save alvin4frnds/41ccf5262bfb5e241ff8a3f5164b08c4 to your computer and use it in GitHub Desktop.
parallel_commands
#!/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