Server Fault is a question and answer site for system and network administrators. 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

My Bash-Foo is not strong. Right now I have something like

function update_project {
  for i in server-{1,2,3,4} ; do
    echo "Updating $i"
    ssh $i "git pull"

The number of servers is growing every day, and since each update takes about 20 seconds, I'd like to do the requests concurrently. What's the best way to do this, while still being able to see the output (e.g. failed merges)?

share|improve this question
up vote 2 down vote accepted

Why are you trying to reinvent the wheel? Just use Capistrano to deploy your project code. It's designed for this exact purpose and runs the deploys in parallel across all of the configured machines.

share|improve this answer

func will allow you to send a command to an arbitrary number of machines, and let you watch the output.

share|improve this answer

There are several parallel ssh projects. Look for pssh.

share|improve this answer

One of the other answers is the correct thing to do, but to directly answer your question, just add an ampersand at the end of your command:

ssh $i "git pull" &
share|improve this answer
The difficulty comes when trying to work out which of the hosts the merge failed on, isn't it? – Jonathan Leffler Jun 27 '10 at 2:55
@Jonathan: Yes, the output would be a jumble. – Dennis Williamson Jun 27 '10 at 3:31

If you have GNU Parallel installed you can do this:

parallel --slf hostfile --nonall --tag git pull

You can install GNU Parallel simply by:

chmod 755 parallel
cp parallel sem

Watch the intro videos for GNU Parallel to learn more:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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