Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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: – depquid Aug 21 '14 at 17:26

3 Answers 3

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

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