0

I have a script that hits an endpoint 50 times. After each of the requests I would like to cancel that request.

for i in $(eval echo {1..50})
do 
  curl --location --request GET 'localhost/endpoint' --header 'Content-Type: application/json' &

  cancel request?
done
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Pbb
  • 408
  • 6
  • 21
  • I'm not sure what you're asking. What are cancellationTokens? You created them, yes? We don't know how to use them or test them. – John Kugelman Sep 30 '21 at 21:53
  • @JohnKugelman The implementation of cancellationTokens is outside of the scope of the question. I would like to cancel the curl request in the shell script. thanks – Pbb Sep 30 '21 at 21:57
  • Do you mean you want to kill the curl process? – John Kugelman Sep 30 '21 at 21:58
  • Yes, but i would like the script to continue running. Ex execute each curl 50 times and kill each curl process 50 times – Pbb Sep 30 '21 at 21:59
  • 1
    Does this answer your question? [linux: kill background task](https://stackoverflow.com/questions/1624691/linux-kill-background-task) – John Kugelman Sep 30 '21 at 22:01
  • Seems like i was able to integrate that into my script and have the desired results, thank you! – Pbb Sep 30 '21 at 22:09
  • no need for an extra process, as `for i in {1..10} ; do echo "do something with $i" ; done` will also work. – shellter Oct 02 '21 at 17:28

0 Answers0