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"
done
}
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)?
func will allow you to send a command to an arbitrary number of machines, and let you watch the output.
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.
There are several parallel ssh projects. Look for pssh.
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:
If you have GNU Parallel http://www.gnu.org/software/parallel/ installed you can do this:
You can install GNU Parallel simply by:
Watch the intro videos for GNU Parallel to learn more: https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1