Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created February 29, 2016 17:12
Show Gist options
  • Save imjacobclark/91f27ac86887950d3cc8 to your computer and use it in GitHub Desktop.
Save imjacobclark/91f27ac86887950d3cc8 to your computer and use it in GitHub Desktop.
command-over-several-boxes.sh
#!/bin/bash
HOSTS=();
CMD="$1"
echo "Hit CTRL-C to stop"
sleep 0.5
PIDS=""
for host in ${HOSTS[*]}
do
ssh $host $CMD &
PIDS="$PIDS $!"
done
trap "kill $PIDS" SIGINT
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment