Created
October 13, 2023 15:37
-
-
Save grndvl1/794ef538715f1a8c6cc66cc54d8852db to your computer and use it in GitHub Desktop.
Bash Script Async Curl Commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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