Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

What is the best way to execute 5 curl requests in parallel from a bash script? I can't run them in serial for performance reasons.

share|improve this question
Have you tried searching for parts of your solution? Another SF question seems to be exactly what you're asking for:… – Theuni Dec 9 '12 at 9:47

Use '&' after a command to background a process, and 'wait' to wait for them to finish. Use '()' around the commands if you need to create a sub-shell.


curl -s -o foo && echo "done1" &
curl -s -o bar && echo "done2" & 
curl -s -o baz && echo "done3" &

share|improve this answer

xargs has a "-P" parameter to run processes in parallel. For example:

wget -nv -O- | egrep -o "http://[^[:space:]]*.jpg" | xargs -P 10 -r -n 1 wget -nv


share|improve this answer

I use gnu parallel for tasks like this.

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.