9

I would like to create linux shell script to run CURL command in parallel

For example: I have three command like

  1. curl -s http://localhost/process.php?id=1
  2. curl -s http://localhost/process.php?id=2
  3. curl -s http://localhost/process.php?id=3

I want to call above three command simultaneously.

Any help is appreciated.

JsLearner
  • 446
  • 2
  • 7
  • 17

2 Answers2

12

I think a bash script like:

#!/bin/bash

curl -s http://localhost/process.php?id=1 &
curl -s http://localhost/process.php?id=2 &
curl -s http://localhost/process.php?id=3 &

However, this is starting all tasks as background processes. Don't know how crucial simultaneous starting of the process is.

3

I think you can use & in between the curl commands in a single line like this:

curl -s http://localhost/process.php?id=1 & curl -s http://localhost/process.php?id=2 & curl -s http://localhost/process.php?id=3