From a3199903b64115b9d83493b46ea2a0a1ca6c18db Mon Sep 17 00:00:00 2001 From: James Pannacciulli Date: Fri, 23 Jan 2015 09:40:18 -0800 Subject: parssh - parallel ssh exec w/ custom concurrency - first commit --- pars.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 pars.sh diff --git a/pars.sh b/pars.sh new file mode 100644 index 0000000..345e511 --- /dev/null +++ b/pars.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +parssh () +{ + [[ "$1" == -[0-9]* && "$1" != *[^0-9-]* ]] && { + parssh_concurrency=${1#-} + shift + } + while read host; do + while (( $(jobs -pr | wc -l) >= ${parssh_concurrency:-4} )); do + sleep 1; + done; + ssh -no StrictHostKeyChecking=no $host "$@" & + done +} -- cgit v1.2.3