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?
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With