LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-13-2018, 07:50 PM   #1
bmxakias
Member
 
Registered: Jan 2016
Posts: 254

Rep: Reputation: Disabled
Question Is there any software/way for Linux to run one command and get it executed at 10 web servers?


Hello

Is there any software/way for Linux to run one command and get it executed at 10 web servers at the same time?

I know about tmux and terminator but if i am not wrong i have to run the command on every opened shell window....

A commercial solution also is not a problem as a recommendation....

Thank you

Last edited by bmxakias; 04-13-2018 at 07:57 PM.
 
Old 04-13-2018, 08:09 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,314
Blog Entries: 28

Rep: Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137Reputation: 6137
Take a look at clusterssh. I have heard it highly recommended by a Linux sysadmin.
 
1 members found this post helpful.
Old 04-14-2018, 11:12 AM   #3
BillT440
LQ Newbie
 
Registered: Mar 2018
Posts: 3

Rep: Reputation: Disabled
I use omnitty. It doesn't need X.

http://omnitty.sourceforge.net/


-Bill

Last edited by BillT440; 04-14-2018 at 11:13 AM. Reason: including link
 
1 members found this post helpful.
Old 04-14-2018, 12:33 PM   #4
bmxakias
Member
 
Registered: Jan 2016
Posts: 254

Original Poster
Rep: Reputation: Disabled
Thanks for your replies

clusterssh seems a bit better than omnitty ....

I will wait for any other possible recommendations....
 
Old 04-16-2018, 06:43 AM   #5
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,140

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
For me at home i just run ssh in a for loop to my machines. Never thought to look at other solutions. Something like this?

Code:
for machine in "$@" ; do
  ssh "$USER"@"$machine" "command" &
done
exit 0
I'm hoping someone will suggest a better alternative than this. Seems like a hack, but it works for my usage.

If multiple command lines to run then use a function.

Code:
myfunction () {
  ssh "$USER"@"$1" "command"
  ssh "$USER"@"$1" "command2"
  ssh "$USER"@"$1" "command3"
}

for machine in "$@" ; do
  myfunction "$machine" &
done
exit 0

Last edited by jmgibson1981; 04-16-2018 at 06:53 AM.
 
1 members found this post helpful.
Old 04-16-2018, 07:46 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,474

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
We manage 200+ systems with the Open Source version of Rundeck
 
1 members found this post helpful.
Old 04-18-2018, 01:07 AM   #7
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,781

Rep: Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199
Quote:
Originally Posted by jmgibson1981 View Post
For me at home i just run ssh in a for loop to my machines. Never thought to look at other solutions. Something like this?

Code:
for machine in "$@" ; do
  ssh "$USER"@"$machine" "command" &
done
exit 0
I'm hoping someone will suggest a better alternative than this. Seems like a hack, but it works for my usage.

If multiple command lines to run then use a function.

Code:
myfunction () {
  ssh "$USER"@"$1" "command"
  ssh "$USER"@"$1" "command2"
  ssh "$USER"@"$1" "command3"
}

for machine in "$@" ; do
  myfunction "$machine" &
done
exit 0
Maybe it is more straight to bundle the commands

Code:
mycommands="
command
command2
command3
"

for machine in "$@" ; do
  ssh "$USER"@$machine" "$mycommands" &
done
BTW bash puts "$machine" as job name.
So the jobs command is not giving good information.
Every other shell does it better, substitutes each $machine to the value before putting it into the job list!
 
Old 04-18-2018, 01:11 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
for 6 servers I would also recommend a for cycle or similar. For really big systems (like tens, hundreds of servers) you might try ansible.
or try this: https://www.tecmint.com/using-dsh-di...iple-machines/

Last edited by pan64; 04-18-2018 at 01:12 AM.
 
Old 04-19-2018, 06:24 AM   #9
Bller
Member
 
Registered: Aug 2009
Location: Bucharest, Romania
Distribution: Slackware 14.1
Posts: 228

Rep: Reputation: 17
Automate the task with Ansible, it will use SSH to run any command on multiple servers which you define within an "Inventory" File.

More about this here :

https://www.ansible.com/

Hope it helps

Cheers !
 
Old 04-19-2018, 07:09 AM   #10
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,598

Rep: Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691
Quote:
Originally Posted by bmxakias View Post
Hello

Is there any software/way for Linux to run one command and get it executed at 10 web servers at the same time?

I know about tmux and terminator but if i am not wrong i have to run the command on every opened shell window....

A commercial solution also is not a problem as a recommendation....

Thank you
Yes. Many.
Look up "mpssh" as one example.
 
1 members found this post helpful.
Old 04-19-2018, 10:30 AM   #11
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
The terminator terminal-emulator has a "broadcast" feature,
Send one command to "tabs"

https://unix.stackexchange.com/quest...simultaneously
 
1 members found this post helpful.
Old 04-13-2019, 11:18 AM   #12
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by frankbell View Post
Take a look at clusterssh. I have heard it highly recommended by a Linux sysadmin.
Heh... I might have been that admin. However, I just built clusterssh on a recent Tumbleweed installation and it failed to pass all the tests. I installed it anyway and it fails to pass along my credentials and prompts for a password in all the xterms it pops up. (Oh good! More debugging!) If it even pops them up, that is. Tools like Ansible (recommended in another reply) might be OK for some things but being able to do an ad hoc command on a bunch of systems and inspect the responses is invaluable. I haven't seen any Linux distributions include clusterssh/cssh in any of their repositories. Pity.
 
Old 04-14-2019, 08:17 AM   #13
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
I used clusterssh in the past to manage 6 servers, both physical and containers. Clusterssh worked great but required me to install too many perl dependencies on Slackware. I switched to "tmux with tm", a helper script found here: https://blog.ganneff.de/2013/03/tmux...ust-nicer.html and found it worked for me without needing additional dependencies.

I like both clusterssh and "tmux with tm" for a small group of servers. They both can multiplex commands to all servers simultaneously or switch back and forth from non-multiplex mode to isolate commands to a specific server. Since I found "tmux with tm" I haven't looked back to use clusterssh.
 
Old 04-16-2019, 05:02 AM   #14
Adrianali
LQ Newbie
 
Registered: Dec 2018
Location: Argentina
Distribution: OpenBSD, Gentoo Linux
Posts: 12

Rep: Reputation: Disabled
Quote:
Originally Posted by jmgibson1981 View Post
For me at home i just run ssh in a for loop to my machines. Never thought to look at other solutions. Something like this?

Code:
for machine in "$@" ; do
  ssh "$USER"@"$machine" "command" &
done
exit 0
I'm hoping someone will suggest a better alternative than this. Seems like a hack, but it works for my usage.

If multiple command lines to run then use a function.

Code:
myfunction () {
  ssh "$USER"@"$1" "command"
  ssh "$USER"@"$1" "command2"
  ssh "$USER"@"$1" "command3"
}

for machine in "$@" ; do
  myfunction "$machine" &
done
exit 0
An interesting option to the 'for' cycle is 'parallel' command.
 
Old 04-17-2019, 06:51 AM   #15
tyler2016
Member
 
Registered: Sep 2018
Distribution: Debian, CentOS, FreeBSD
Posts: 243

Rep: Reputation: Disabled
I use the community version of SaltStack to manage my machines.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Run the same command on many Linux servers at once LXer Syndicated Linux News 0 05-23-2014 03:20 PM
LXer: Run the same command on many Linux servers at once LXer Syndicated Linux News 0 06-12-2013 05:21 AM
ShellScript executed from command prmpt but not executed from crontab or at command BMMadhav Linux - Newbie 1 11-16-2012 07:20 PM
[SOLVED] Xwindow's program will not run when executed on boot or when executed remotely richman1234 Programming 2 10-08-2010 01:32 PM
python, tkinter, command is executed when program is run not when button clicked deathalele Programming 5 06-15-2009 03:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration