Created
February 27, 2019 19:55
-
-
Save janschumann/e844bdb584d4d9bb6b3cf69d47ba300d to your computer and use it in GitHub Desktop.
Execute command in multiple directories in parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# example: run puppet tests in all modules | |
CMD="pdk test unit --format=junit:report.xml &> pdk_test.log" | |
for d in $(ls -d); do { | |
cd $d | |
$CMD & pid=$! | |
PID_LIST+=" $pid"; | |
cd .. | |
} done | |
trap "kill $PID_LIST" SIGINT | |
echo "Parallel processes have started"; | |
wait $PID_LIST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment