15

I use a tool to monitor if the web-page is up and running.

The tool uses curl command internally to fetch the output.

However, when a web-page takes longer time to respond, it results back with a TIMEOUT error. There is no way that I can increase the timeout from the tool.

Is there any way to set/modify the timeout period for a response from a web-page?

Is there any variable that can be modified?

21

You can use -m option:

-m, --max-time <seconds>
              Maximum time in seconds that you allow the  whole  operation  to
              take.   This is useful for preventing your batch jobs from hang‐
              ing for hours due to slow networks or  links  going  down.   See
              also the --connect-timeout option.

              If this option is used several times, the last one will be used.

This includes time to connect, if you want to specify it separately, use --connect-timeout option.

4

Normally you'd do this with an option on the command line when curl is invoked. But since you can't change this, there's another way - you can create a config file for curl. On unix, curl will first look in the home directory of the user that's running curl for a file called .curlrc. Create that file with the line

connect-timeout = 10

to reduce the timeout to 10 seconds. Or you can set a max time for the entire operation, with the option max-time:

max-time = 10
  • That's a great idea..but I was also wondering, if there is any particular env variable for that or something that can be set from the backend like ulimit to increase the FD count? – user80040 Aug 7 '14 at 11:06
  • I can't find anything like that in the man page. – Jenny D Aug 7 '14 at 11:41
4

curl has a "connect timeout" option:

--connect-timeout <seconds>

If your "tool" is a script, you could manually edit that into there. But https://unix.stackexchange.com/a/148926/77959 is even better - edit the curl-config!

  • Ya..adding the config is rather a bright idea..but I was also wondering, if there is any particular env variable for that or something that can be set from the backend like ulimit to increase the FD count? – user80040 Aug 7 '14 at 11:05
  • @user80040 No, there isn't. There's no “backend”, the timeout isn't some kind of system limitation. Curl does the web request and decides to time out based on its configuration. – Gilles 'SO- stop being evil' Aug 7 '14 at 21:11
0

From Curl you can use this option --connect-timeout: Maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once curl has connected this option is of no more use. See also the --max-time option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.