A small script to allow running the same command on multiple servers. The commands are ran in series so that if you see an error somewhere, you can quickly bail out with Ctrl + C and avoid further damage to your servers.
Run as:
run-on dbserver.mysite.com frontend.mysite.com 'date; df -h /tmp'
Output:
Running the following command on 2 server(s):
date; df -h /tmp
---> Running command on dbserver.mysite.com as root:
Fri Oct 25 06:40:58 MST 2013
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1.1T 92G 952G 9% /tmp
---> Running command on frontend.mysite.com as root:
Fri Oct 25 06:41:02 MST 2013
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 1.7T 88G 1.5T 6% /tmp
To install, execute the following command in one go in your shell:
mkdir -p ~/bin && \
curl 'https://gist.github.com/mitio/7154639/raw/run-on' > ~/bin/run-on && \
chmod a+rx ~/bin/run-on
If ~/bin
is in your $PATH
, you'll be able to use run-on
directly. Otherwise, type ~/bin/run-on
.