Reputation: 4002
I have a bash script which does the following:
for server in $servers; do # servers from input
ssh $server <some long running command...>
done
# Rest of the code...
I would like to parallelize the ssh
calls, but only continue to the rest of the code after all the servers have finished. I noticed similar questions here but all had either a fixed number of processes, or did not wait for finish. I would also accept an answer like don't do it in bash!
. Thanks.
Upvotes: 0
Views: 41
Reputation: 88969
Replace
ssh $server <some long running command...>
by
ssh $server <some long running command...> &
and replace
done
by
done
wait
Upvotes: 3