简体   繁体   中英

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.

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.

我想你可以在一行中的curl命令之间使用&,如下所示:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM