I'd like to use curl
to send a HTTP HEAD request to a URL to verify that it is working correctly (server is up and sends a successful response). At the end, I need the final HTTP response code returned and URL (after following any redirects). Finally, I need to set a hard timeout (a period of time after which the call will fail, regardless of where in the request curl
is).
Does curl
support all this? What options do I need to use to accomplish this?
curl -I
will generate a HEAD request.Adding the
-L
option will make it follow redirects.Timeouts can be controlled with several options depending on which bit of the request you want to time out.
From the man page:
Another couple of timeout-related options also worth looking at are: