Created
March 16, 2017 21:20
-
-
Save ric2b/3a612dfcde8d52a909da9d9808cd5c92 to your computer and use it in GitHub Desktop.
run a command in multiple machines
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 | |
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