Hintswen
Hintswen

Reputation: 4007

curl retry on timeout

I've written a shell script that has a function like this:

function getpage {
        echo $1
        curl -O "http://www.example.com/$1" -b cookie.txt -s
}

The problem is if the website times out then that page will be skipped, I need it to re-try if it times out (I will also be putting in a 60 second timeout).

How do I do this?

Upvotes: 6

Views: 13771

Answers (1)

Andrew Sledge
Andrew Sledge

Reputation: 10351

You can use --retry <num> for forced retries. An alternate way is to add -w http_code to see what the return code is...if it's not 200 then try again.

Upvotes: 9

Related Questions