Execute commands on multiple servers in parallel

KUPI

New Member
Credits
44
Hello,

Happy new year to everyone.

I want to execute certain commands on multiple servers. I use to do this using a for loop. But it takes long time. For example, if I have 1000 servers, script should run the cmd on 50 servers in parallel. so that we can achieve the work fast.

I don't know python where we can use thread concept to achieve this. I know only shell script.
Also we are not allowed to install / use any tool like pssh..
So is there any logic we can use in bash script to achieve this.

Thanks in advance,
Kupi.
 


f33dm3bits

Gold Member
Gold Supporter
Credits
9,083
You can use ansible for that, since ansible runs through ssh, either a playbook or a ad-hoc command.
 

wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
9,809
This should likely be in Servers, I'll take @f33dm3bits 's recommendation on where to move it.

Cheers

Wizard
 

f33dm3bits

Gold Member
Gold Supporter
Credits
9,083
This should likely be in Servers, I'll take @f33dm3bits 's recommendation on where to move it.

Cheers

Wizard
I would say "General Servers" since OP is trying to run a something on multiple servers, as well as the tool I recommended that they could use is also used a tool used for server configuration since it's a configuration management tool.
 

wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
9,809
Thanks @f33dm3bits , moving us there now, hang on to your hats.
 

KUPI

New Member
Credits
44
You can use ansible for that, since ansible runs through ssh, either a playbook or a ad-hoc command.
Thanks for the reply.
Actually we are not allowed to install Ansible in our environment :(


we have a admin server. from there we can connect all the other linux servers through ssh.
At the time of patching , we use to take prechecks (fstab, network configuration, etc..) from all client servers. as of now i'm using for loop to take the details.
I am trying for a logic in shell script, where I can take these prechecks from multiple servers in parallel.
 

f33dm3bits

Gold Member
Gold Supporter
Credits
9,083
Ansible only needs to be installed on your admin server, if you don't have the rights to install it. You can just create a python-virtualenv in your homedir and install ansible there. On the remote server you don't need ansible installed but just a user ansible will use to run as since ansible uses ssh.

What's the point of having servers and an admin server if you aren't allowed to use/install tools to efficiently manage your servers? The other option is to run remote ssh commands in a loop, which is not very efficient since tools such as ansible allow you to manage your systems efficiently.
 
Last edited:

Norky

New Member
Credits
8
Ansible is great, but if you really cannot use it, then ClusterShell might be useful, specifically the clush command. It's available from EPEL, so that might help you persuade people that it's trustworthy software.
 
Last edited:

Members online


Latest posts

Top