Using curl to make a HEAD request with a hard timeout

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:

--connect-timeout <seconds>
          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 -m/--max-time 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 hanging for hours due to slow networks or links going down.  See also the --connect-timeout option.

Another couple of timeout-related options also worth looking at are:

--retry
--retry-delay
--retry-max-time