Skip to content

Instantly share code, notes, and snippets.

@ric2b
Created March 16, 2017 21:20
Show Gist options
  • Save ric2b/3a612dfcde8d52a909da9d9808cd5c92 to your computer and use it in GitHub Desktop.
Save ric2b/3a612dfcde8d52a909da9d9808cd5c92 to your computer and use it in GitHub Desktop.
run a command in multiple machines
#!/bin/bash
user=myuser
# use ssh keys for simple login
machines=(ip1 ip2)
for machine in $(machines[*])
do
echo "running $1 on $user@$machine"
echo "$machine: $(ssh $user@$machine "$1") &
done
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment