Running commands on multiple servers

4,207

Solution 1

I know some tools for that, but the easiest is Fabric. Take a look and tell me what do you think.

Solution 2

Sounds like you're looking for GNU Parallel. That's pretty much exactly what it was written for. In your case, you would do:

parallel ./remote --sshloginfile ALL_SERVERS_IP

The above assumes that ALL_SERVERS_IP is a text file with one IP or hostname per line. If they can have different logins, make the list like so:

[email protected]
[email protected]
[email protected]

Solution 3

Yes. Try pdsh, which will execute a command on multiple remote hosts simultaneously. Your task could be written like so:

pdsh -w ssh:$(echo $(<ALL_SERVERS) | sed -e 's/ /,/g') 'printf "%s\n" ...'
Share:
4,207

Related videos on Youtube

TheEagle
Author by

TheEagle

Updated on September 18, 2022

Comments

  • TheEagle
    TheEagle almost 2 years

    I'am trying to make a navigation bar horizontal but at the moment its vertical. Any help would be great. The problem is that its vertical. I have made the list in html and then used my other file in css to edit it.

    HTML:

    <html>
    <head>
        <link rel="stylesheet" href="Style/style.css" type="text/css"/>
    </head>
    <body>
    <div class="horizontal">
    <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Articles</a></li>
    </ul>
    </div>
    
    </body>
    <html>
    

    CSS:

    div.horizontal
    {
    width:100%;
    height:63px;
    }
    div.horizontal ul
    {
    list-style-type:none;
    margin:0;
    padding:0;
    }
    div.horizontal li
    {
    float:left;
    }
    div.horizontal a
    {
    display:block;
    width:86px;
    }
    div.horizontal a:link,div.horizontal a:visited
    {
    font-weight:bold;
    color:#FFFFFF;
    background-color:#98bf21;
    text-align:center;
    padding:4px;
    text-decoration:none;
    text-transform:uppercase;
    }
    div.horizontal a:hover,div.horizontal a:active
    {
    background-color:#7A991A;
    }
    
  • PlantTheIdea
    PlantTheIdea over 11 years
    it does with a little trick: stackoverflow.com/questions/3754469/…
  • Oleksandr
    Oleksandr almost 10 years
    I checked on the central server and couldn't find parallel on it.
  • terdon
    terdon almost 10 years
    @user67186 you only need to install it on your machine, the one you will launch the job from.
  • Ole Tange
    Ole Tange almost 10 years
    Use a bash function to give the 'printf/hostname' stuff to run. Then use --env to export that function to the remote server: parallel --env myfunc --slf ALL_SERVERS_IP --nonall myfunc
  • Oleksandr
    Oleksandr almost 10 years
    All anwsers are useful but I can choose one solution. Thanks!
  • WangJie
    WangJie almost 10 years
    You're welcome man. I'm glad to help.
  • Jenson
    Jenson over 8 years
    @terdon How do you have to install parallel? Can't find anything useful.
  • terdon
    terdon over 8 years
    @Jenson see the link in my answer. Most Linux distributions (probably all) will have it in their repositories as parallel. For others, the link provides download packages.