Search code examples
bashcurlxargs

Using xargs to make parallel curl API calls


When i run the following command:

seq 1 1 | xargs -I % -P 5 curl -k --user user:pass "https://localhost:port/api"

I only get one response back. I would have expected to get 5 responses since i'm running the curl command 5 times in parallel.

Is this correct or should i see 5 responses?


Solution

  • The problem is on your seq command the range is from 1 to 1.

    Try seq 1 5 instead.