fanout, a super useful linux script if you manage multiple, similar servers

2 minute read Published:


I love this fanout script for running the same command on multiple servers, just in case you’re interested:

http://www.stearns.org/fanout/fanout

[[email protected] scripts]# fanout "$SERVERS" "cp /root/.ssh/authorized_keys /home/user/.ssh/"<br /> Starting [email protected]<br /> Starting [email protected]<br /> Starting [email protected]<br /> Starting [email protected]<br /> Starting [email protected]<br /> Starting [email protected]<br /> Fanout executing "cp /root/.ssh/authorized_keys /home/user/.ssh/"<br /> Start time Wed Dec 23 23:45:35 EST 2009 , End time Wed Dec 23 23:45:47 EST 2009<br /> ==== As root on db1 ====

==== As root on db2 ====</p> <p>==== As root on nas ====</p> <p>==== As root on www1 ====</p> <p>==== As root on www2 ====</p> <p>==== As root on www3 ====</p> <p>Exiting fanout, cleaning up...done.</p> <p>[[email protected] scripts]# fanout "$SERVERSWWW" "/etc/init.d/httpd restart"<br /> Starting [email protected]<br /> Starting [email protected]<br /> Starting [email protected]<br /> Fanout executing "/etc/init.d/httpd restart"<br /> Start time Wed Dec 23 23:50:52 EST 2009 , End time Wed Dec 23 23:50:59 EST 2009<br /> ==== As root on www1 ====<br /> Stopping httpd: [ OK ]<br /> Starting httpd: [ OK ]</p> <p>==== As root on www2 ====<br /> Stopping httpd: [ OK ]<br /> Starting httpd: [ OK ]</p> <p>==== As root on www3 ====<br /> Stopping httpd: [ OK ]<br /> Starting httpd: [ OK ]</p> <p>Exiting fanout, cleaning up...done.</p> <p>

[[email protected] scripts]# echo $SERVERS<br /> [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]<br /> [[email protected] scripts]# echo $SERVERSWWW<br /> [email protected] [email protected] [email protected]

A great way to execute the same commands on multiple servers… if you export the $SERVERS to a standard list, in your .bashrc or whatnot… it’s even easier. Of course, you’ll probably want to setup authorized_keys for your servers so that you don’t have to authenticate to each…

Published by in geek and linux using 275 words.

comments powered by Disqus