I was trying to use a linux command repeatedly and I decided to use bash scripting. The command is curl and it has blue screen given to the target web server. I was doing this as a pentester in my company. So I wanted to repeat this curl command infinite times and I was successful with bash script loop commands. The final command is in the following:

Ubuntu 14.04 LTS Terminal:

while :; do $(curl -v -H "Range: bytes=18-18446744073709551615" & sleep 5 & pkill curl); done

But there is a something which I couldn't understand clearly: According to some articles and question-answers, each command in (command1 & command2 & command3 as single line) runs asynchronously and therefore they are running simultaneously without waiting one another. But in the above attacking code's result, curl's output is repeated in "every 5 seconds". That is, curl is running, then 5 seconds is waited, then curl is aborted. After that, curl is executed again. Therefore, the output is appeared again after every 5 seconds. So these commands interfere to each other. But internet articles and question-answers says its opposite. Can anyone make this point clear?

Note: By force of curl's attacking parameter, curl is pending. Not completing. Therefore, I am using sleep and then pkill command, respectively. Thereby, I can use curl command properly and repeatedly with attacking parameter.

Related Links:

1) (command1 & command2 & command3 &) Runs multiple jobs in parallel

How to run multiple background jobs in linux?

2) (command1 & command2 & command3 &) Runs at the same time, in separate sub-shells


3) Asynchronous (multi-Threaded) Diagram Sample


1 Answer 1


You can think of the execution like this:

  • curl -v ..., sleep 5, pkill curl are almost simultaneously executed
  • It's very possible that when pkill curl runs, the first curl command has just received some data. And then it gets killed.
  • The command substitution $( ... ) wrapping the whole thing waits until all commands end. See Why won't function return until background process ends? Only then does it present all the output it has, which is whatever data curl had received. Run, say, echo $(date & sleep 5); date to verify this - you'll have to wait for the first output to appear.
  • Repeat.

So you see the output of curl (rather, you're executing the output of the command substitution here, I'm not sure why) some five seconds after curl has been killed.

Note: By force of curl's attacking parameter, curl is pending.

No idea what you mean by "attacking parameter".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .