On 03/04/2017 06:41 AM, bruce wrote:
Ok guys,
I know this isn't strictly "Fed" related, but the group might have
suggestions.
My use case, the process has a number of remote servers. I'd like to
be able to run a bunch of commands on the remote servers as fast as
posible. The initial thought was to loop through the different
IPAddresses, and SSH into each server, to run the commands.
However, this process was still "sequential" in that each SSH session
needs to complete, prior to running the next server/ssh command.
So, my question/need -- is to figure out how to run a ssh as a
background on the local server. This approach would/should allow the
process to quickly fire off commands to the remote ipaddresses/servers
in a much faster/parallel manner.
sortof:
foreach iplist as ipaddress
ssh user1@ipaddress command & (assuming that the '&' runs the local
ssh in the background -- it doesn't!)
Running "stuff" on the remote can occur in a "Screen" session, which
would allow the ssh process to fire off the remote cmd, but it still
doesn't run the local ssh as a "background" process..
Rick has mentioned/discussed the "Screen" function in past threads.
Yes, screen is useful. Have a look a the "pdsh" command and its
companion, "dshbak". I use it a lot to manage our storage systems.
For example, each of the machines involved has an "/etc/machines" file
of:
seg1-r0
seg2-r0
seg3-r0
seg4-r0
seg5-r0
seg6-r0
They also all have shared ssh keys. If I use the command:
pdsh -a "ps ax" | dshbak
on one of them, they all will do a "ps ax" command asynchronously and
dshbak will sort the output so that the output of each machine is kept
together. Similarly,
pdsh -w seg[1,2]-r0 "ps ax" | grep dshbak
will only run the command on the first two machines. You get the idea.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital ricks(a)alldigital.com -
- AIM/Skype: therps2 ICQ: 226437340 Yahoo: origrps2 -
- -
- Tempt not the dragons of fate, since thou art crunchy and taste -
- good with ketchup. -
----------------------------------------------------------------------