Skip to content

Instantly share code, notes, and snippets.

@Dih5
Created March 17, 2016 10:57
Show Gist options
  • Save Dih5/1aeb7bd03d9a5a7677dd to your computer and use it in GitHub Desktop.
Save Dih5/1aeb7bd03d9a5a7677dd to your computer and use it in GitHub Desktop.
Run a command in a list of servers. (Note there are better tools to do this like pssh pdsh, ...)
#!/bin/bash
#Server list:
declare -a arr=("server1" "server2" "server3")
#Command to execute:
cmd="./cpuuse.sh"
for i in "${arr[@]}"
do
echo "***Connecting to $i***"
ssh "$i" "$cmd"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment