Comment Comment by ktopaz Years ago I wrote this tiny script:<run-on-all.sh> #!/bin/bash clusterfile=$1 cmd="source /etc/profile; $2" ssh='ssh -n -A -o BatchMode=yes -o ConnectTimeout=10 -o LogLevel=quiet' #add "-o ConnectTimeout=x" for timing out the ssh connection after x seconds #redircting stdin for ssh command to /dev/null (using switch "-n" for ssh) since otherwise ssh command breaks bash's "while" loop #reference: http://www.unix.com/shell-programming-scripting/38060-ssh-break-while-loop.html echo while read line; do echo "@==============@ running on $line @==============@" echo echo $ssh $line "$cmd" echo echo done < $clusterfile echo echo echo "==============> FINISHED RUNNING for $clusterfile <==============" All one needs to do is call it like so: ./run-on-all.sh /path/to/cluster/file/list-of-servers-here.txt "sleep 60; reboot" parent ktopaz 7 years ago
<run-on-all.sh>
All one needs to do is call it like so: ./run-on-all.sh /path/to/cluster/file/list-of-servers-here.txt "sleep 60; reboot"