Nagarajan S Nagarajan S - 4 months ago 59
Linux Question

Linux - Shell script run curl command in parallel

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.

Answer

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.