Run cURL command every 5 seconds
You can run in while loop.
while sleep 5; do cmd; done
Edit:
If you don't want to use while..loop
. you can use watch command.
watch -n 5 cmd
How can I run multiple curl requests processed sequentially?
It would most likely process them sequentially (why not just test it). But you can also do this:
make a file called
curlrequests.sh
put it in a file like thus:
curl http://example.com/?update_=1
curl http://example.com/?update_=3
curl http://example.com/?update_=234
curl http://example.com/?update_=65save the file and make it executable with
chmod
:chmod +x curlrequests.sh
run your file:
./curlrequests.sh
or
/path/to/file/curlrequests.sh
As a side note, you can chain requests with &&
, like this:
curl http://example.com/?update_=1 && curl http://example.com/?update_=2 && curl http://example.com?update_=3`
And execute in parallel using &
:
curl http://example.com/?update_=1 & curl http://example.com/?update_=2 & curl http://example.com/?update_=3
How to write output of looped curl command to file
You can do this:
while :; do
curl --location --request POST 'https://api.website.com/Auth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: blablabla' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=username' \
--data-urlencode 'password=password'
sleep 2 || break
done >> file.txt
How to repeat Chrome requests as curl commands?
The way I did it was:
- Access websites when the developers tools open.
- Issue requests, make sure they are logged in the console.
- Right click on the requests, select 'Save as HAR with content', and save to a file.
- Then run the following php script to parse the HAR file and output the correct curls:
script:
<?php
$contents=file_get_contents('/home/elyashivl/har.har');
$json = json_decode($contents);
$entries = $json->log->entries;
foreach ($entries as $entry) {
$req = $entry->request;
$curl = 'curl -X '.$req->method;
foreach($req->headers as $header) {
$curl .= " -H '$header->name: $header->value'";
}
if (property_exists($req, 'postData')) {
# Json encode to convert newline to literal '\n'
$data = json_encode((string)$req->postData->text);
$curl .= " -d '$data'";
}
$curl .= " '$req->url'";
echo $curl."\n";
}
CURL: how to run a single curl command 100 times?
You could achieve it by using the below script:
#!/bin/bash
for i in $(eval echo {1..$1})
do
curl -i -H 'Content-Type: text/plain' -X POST -d @hundredencoded http:///aaa/bbb/message &
done
Related Topics
How to Fix Java.Lang.Module.Findexception: Module Java.Se.Ee Not Found
Facing an Error "*** Glibc Detected *** Free(): Invalid Next Size (Fast)"
How to Change Permissions For a Folder and Its Subfolders/Files
How to Install Gcc 4.9.2 on Rhel 7.4
How to Use Sed to Change My Configuration Files, With Flexible Keys and Values
How to Run a Shell Script When a File or Directory Changes
How to Loop Over the Output of a Shell Command
Get Program Execution Time in the Shell
Exit Code of Variable Assignment to Command Substitution in Bash
Execute Command After Every Command in Bash
What Killed My Process and Why
Save Modifications in Place With Awk
Redirect All Output to File in Bash
How to Recursively Find All Files in Current and Subfolders Based on Wildcard Matching
Get Destination Address of a Received Udp Packet