Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curl: sleep/delay between requests

Tags:

curl

flurry

I am trying to download flurry exception logs using the following command.

curl --cookie ./flurry.jar -k -L "https://dev.flurry.com/exceptionLogsCsv.do?projectID=49999&versionCut=versionsAll&intervalCut=allTime&direction=1&offset=[0-100:10]" --output "exception#1.csv"

It works fine and it downloads the csv files based on the offset(10,20,30 etc). I would like to insert a delay between each request. Is it possible to do that in CURL?

like image 705
rfsk2010 Avatar asked Feb 09 '12 14:02

rfsk2010


People also ask

How do you delay curls?

It is an infinite loop, and the delay is given by the sleep command. The sleep command is not available on Windows. But you can use ping to "emulate" it. Just replace the XX above with the number of seconds you want to delay.

Does Curl send a GET request?

To make a GET request using Curl, run the curl command followed by the target URL. Curl automatically selects the HTTP GET request method unless you use the -X, --request, or -d command-line option.


1 Answers

Using bash shell (Linux) :

while :
do
    curl --cookie ./flurry.jar -k -L "https://dev.flurry.com/exceptionLogsCsv.do?projectID=49999&versionCut=versionsAll&intervalCut=allTime&direction=1&offset=[0-100:10]" --output "exception#1.csv"
    sleep 5m
done

It is an infinite loop, and the delay is given by the sleep command.

Edit. On Windows machine, you can do this trick instead :

for /L %i in (0,0,0) do (
    curl --cookie ./flurry.jar -k -L "https://dev.flurry.com/exceptionLogsCsv.do?projectID=49999&versionCut=versionsAll&intervalCut=allTime&direction=1&offset=[0-100:10]" --output "exception#1.csv"
    ping -n XX 127.0.0.1>NUL
)

The sleep command is not available on Windows. But you can use ping to "emulate" it. Just replace the XX above with the number of seconds you want to delay.

like image 143
Muhammad Abrar Avatar answered Sep 29 '22 20:09

Muhammad Abrar