Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

command line curl timeout parameter

I am using command line curl program and interestingly I could not find a timeout parameter for command line curl. I read the man pages for curl and googled but still could not find one. The libcurl has timeout parameters(CURLOPT_TIMEOUT) but that is not what I am looking for. I am looking for the command line curl timeout parameter.

There is --max-time parameter which is for maximum amount of time to keep the connection open and --connect-timeout which is for the connection phase of curl, but none for the normal timeout.

Does anyone know about this parameter?

like image 495
user1519575 Avatar asked Jul 12 '12 03:07

user1519575


People also ask

How do I check my curl timeout?

Tell curl with -m / --max-time the maximum time, in seconds, that you allow the command line to spend before curl exits with a timeout error code (28). When the set time has elapsed, curl will exit no matter what is going on at that moment—including if it is transferring data. It really is the maximum time allowed.

Why does curl connection timeout?

If your DNS server is not working correctly, then this may also fail HTTP requests and cause the cURL timeout error in WordPress. A poorly configured WordPress hosting server may simply have a very low timeout threshold which may stop certain WordPress processes to run properly.

How do you respond to curl wait?

The best method of achieving this is by using the --connect-timeout option. You can specify the timeout in seconds (e.g., 5), in milliseconds (e.g. 0.001), or as a combination of seconds and milliseconds (e.g., 4.20), and curl will use that time as the maximum time for a response until a connection is dropped.


1 Answers

Option --max-time does exactly what you need: "Maximum time in seconds that you allow the whole operation to take". You just think wrong about it.

# 10 seconds for the full operation to complete
curl --max-time 10 https://example.com
like image 113
Pavel Vlasov Avatar answered Sep 21 '22 06:09

Pavel Vlasov