run command on multiple computers (nodes)

run-all () {
    GROUP=$1
    shift
    for host in `cat /root/.hosts.$GROUP`; do
        echo $host
        ssh $host "$*"
    done
}

usage:

$ run-all web-servers apt-get upgrade -y

/root/.hosts.web-servers

w1
w2
w3
avatar

About tompos

Hungary, Budapest
This entry was posted in IT. Bookmark the permalink.

Leave a Reply