[TriLUG] Issuing a command to multiple machines simultaneously

Maarten Lippmann m.w.lippmann at gmail.com
Tue Jun 3 14:57:32 EDT 2008


create a shell script with a for loop:

something like


-----------

#!/bin/bash

systemHostNames=( sysa sysb sysc )
for name in ${systemHostNames[@]}
do
    ssh $name 'command here'
done

---------

i often do this type of thing by hand in bash when I need to iterate
through ip adresses:

for ((i=101;i=150;i++)) do
ssh 192.168.0.$i 'cat /var/log/blahblah'
done

(might be a spelling error


On Tue, Jun 3, 2008 at 2:20 PM, Paul McLanahan <pmclanahan at gmail.com> wrote:
> Hi All,
>
> I manage a few Linux boxen at $work. They're not all exactly alike,
> but the are all running Ubuntu Hardy Server, and quite often I have to
> issue the same command to all of them to do things like package
> upgrades, installs, etc.. I'd like to setup a system that will allow
> me to issue the command in a client of some type, which will cause the
> command to run of all of the machines, and send the output back to me.
> I've seen this done in the past, but I can not seem find how it was
> done, and my googling has turned up a couple of rsh tutorials, but
> unless I'm missing something, just rsh isn't going to get this done.
>
> Thanks for any advice,
>
> Paul McLanahan
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG FAQ  : http://www.trilug.org/wiki/Frequently_Asked_Questions
>



-- 
Please avoid sending me Word or PowerPoint attachments.
Use plain text, HTML or PDF (adobe acrobat) in stead.
See http://www.gnu.org/philosophy/no-word-attachments.html



"Is 't noodlot, dat ick vall', van eere en staet berooft,
Laet vallen, als ick vall', met deze kroone op 't hooft,
Dien scepter in de vuist, dien eersleip van vertrouden,
En zoo veel duizenden als onze zyde houden.
Dat valle streckt tot eer, en onverwelckbren lof:
En liever d' eerste Vorst in eenigh laeger hof,
Dan in 't gezalight licht de tweede, of noch een minder
Zoo troost ick my de kans, en vrees nu leet noch hinder."



More information about the TriLUG mailing list