Skip to content

Instantly share code, notes, and snippets.

@grndvl1
Created October 13, 2023 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grndvl1/794ef538715f1a8c6cc66cc54d8852db to your computer and use it in GitHub Desktop.
Save grndvl1/794ef538715f1a8c6cc66cc54d8852db to your computer and use it in GitHub Desktop.
Bash Script Async Curl Commands
#!/bin/bash
# when makeing a curl command you can call them asyncly and not have to wait for each one to finish.
# its very simple and took a bit to find by googling it. The searches turned up garbage until I
# stumbled on this solution.
# the '&' sign at the end is what make its run in its own space, daemon if you will
for ((i=0; i<30; i++)); do
curl -X 'POST' \
'https://some url' \
-H 'accept: application/json' \
-d '{
... some content
}' &
done
# then before you exit the script call wait
wait
# so that is it just add and '&' to your curl and then 'wait' at end of script
# I did this as the the parallel curl options did not work for me
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment