w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to run multiple curl commands in parallel over https

Just launching your processes in background sounds easy and is really tempting, but unless you are iterating on a small set, you would rather not do that. You can hog the CPU and/or network, since you do not have any control on the amount of concurrent download processes.

I would propose using xargs.

seq 1 9 | 
         --replace time curl -k https://localhost:{}/fooBar 

xargs's --replace automatically sets the number of arguments per command invocation to 1 (-n 1) and replaces {} with each argument given in stdin.

If you want a more complex scenario (such as registering the timing of each individual request), you might want to invoke a wrapping script instead.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.