Run the same command on many Linux servers at once

Rob —  June 11, 2013 — 6 Comments

Ever have to check a list of Linux servers for various things like what version of CentOS they’re running, maybe how long each has been running to get an uptime report? You can – and it’s very easy to get going with it.

gsh allows you to run commands on multiple hosts by adding tags to the gsh command.

Important things to remember:

  • /etc/ghosts contains a list of all the servers and tags
  • gsh is a lot more fun once you’ve set up ssh keys to your servers

Examples to use:

List uptime on all servers in the linux group:

Check to see if an IP address was blocked with CSF by checking the csf and csfcluster groups/tags:

Unblock an IP and remove from /etc/csf.deny from all csf and csfcluster machines

Check the linux kernel version on all VPS machines running centos 5

Check cpanel version on all cpanel machines

The full readme is located here: http://outflux.net/unix/software/gsh/

Here’s an example /etc/ghosts file:

Related posts from Linux Brigade!

  • Check, repair, optimize all databases with one commandCheck, repair, optimize all databases with one command My server had some tables marked as ‘crashed’ in one of the databases.. the server had recently gone down pretty harshly so I wanted to go through and check, repair and optimize all of the […]
  • Migrating from Plesk to cPanel via commandlineMigrating from Plesk to cPanel via commandline If you’re anything like me, you prefer to do things via command line (CLI) rather than relying on a GUI to do most things in Linux. You also realize that while some of us don’t like to use […]
  • Install XenServer via usb flash driveInstall XenServer via usb flash drive USB Flash drives are getting cheaper and cheaper lately. I just picked up few at staples – 16GB flash drives for just under $8. I like to use them to install Linux – I always seem to […]
  • Delete cPanel account error_log filesDelete cPanel account error_log files If you have a large number of accounts on your server, you may also be wasting a lot of space with the error_log files in each account. Some can get very large – and while you want to […]
  • Migrate WHM/cPanel from one server to a new one (script)!Migrate WHM/cPanel from one server to a new one (script)! We’ve started a site to house a script that will migrate your full WHM/cPanel server to new hosting. This takes the new WHM/cPanel backup files and will restore them including system […]

6 responses to Run the same command on many Linux servers at once

  1. That is very useful actually. I use to run each one manually so this will save me a lot of time. Your guides are very easy to follow and thanks for providing the link to the full readme.

  2. Is this the gsh you are using?
    http://outflux.net/unix/software/gsh/

  3. That looks like a really cool tool, I will have to test that out. It seems like a great way to manage updates to large groups of machines in a controlled way.

    Now I need to set up ssh keys to all of my machines.

  4. Another excellent guide. Thank you. This will improve my productivity quite a bit. Very helpful code, indeed.

Trackbacks and Pingbacks:

  1. Links 13/6/2013: CyanogenMod Gets Incognito Mode | Techrights - June 13, 2013

    […] Run the same command on many Linux servers at once […]

Leave a Reply to synset Cancel reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url=""> 

*