Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I want to execute a process on multiple servers. I am using the following wrapper script. The script moves to servers one at a time. I would like to change it so it can execute on multiple servers. Is there way to do it?

for ip in $(<ALL_SERVERS_IP); do
    # Tell the remote server to start bash, but since its
    # standard input is not a TTY it will start bash in
    # noninteractive mode.
    ssh -q "$ip" bash <<-'EOF'
        printf "%s\n" ================== "$(hostname) ::: Current date : $(date)" \
share|improve this question

marked as duplicate by terdon Aug 22 '14 at 11:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

There are a bunch of options. This blog lists 10: blog.crdlo.com/2010/07/parallel-ssh-tool-roundup.html – depquid Aug 21 '14 at 17:26
up vote 0 down vote accepted

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

share|improve this answer
All anwsers are useful but I can choose one solution. Thanks! – user67186 Aug 22 '14 at 13:18
You're welcome man. I'm glad to help. – Willian Paixao Aug 22 '14 at 20:17

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|improve this answer

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:

share|improve this answer
I checked on the central server and couldn't find parallel on it. – user67186 Aug 21 '14 at 17:53
@user67186 you only need to install it on your machine, the one you will launch the job from. – terdon Aug 21 '14 at 17:55
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 – Ole Tange Aug 22 '14 at 7:08
@terdon How do you have to install parallel? Can't find anything useful. – Jenson Jan 27 at 7:34
@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. – terdon Jan 27 at 10:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.