WGET command retrying to get response

Hi ,

Iam using " WGET " command to hit the URL,i.e. servlet url.

I can trigger the servlet using wget but when servlet is not responding this command retries automatically until it get the positive response from the server.
So this script is running for more than 8 hrs to get the positive response.

My expectation :

This wget should hit the url only once and if it doesnt get positive response from the server with in next half an hour , it should through the mail that servlet is failed.

How to restrict the timings and number of time it should retry hitting the url.

Please advice me,thanks in advance!

From man wget:

       -t number
       --tries=number
           Set number of retries to number.  Specify 0 or inf for infinite
           retrying.  The default is to retry 20 times, with the exception of
           fatal errors like "connection refused" or "not found" (404), which
           are not retried.

You'll probably also be interested in

       -T seconds
       --timeout=seconds
           Set the network timeout to seconds seconds.  This is equivalent to
           specifying --dns-timeout, --connect-timeout, and --read-timeout,
           all at the same time.

           When interacting with the network, Wget can check for timeout and
           abort the operation if it takes too long.  This prevents anomalies
           like hanging reads and infinite connects.  The only timeout enabled
           by default is a 900-second read timeout.  Setting a timeout to 0
           disables it altogether.  Unless you know what you are doing, it is
           best not to change the default timeout settings.

           All timeout-related options accept decimal values, as well as sub-
           second values.  For example, 0.1 seconds is a legal (though unwise)
           choice of timeout.  Subsecond timeouts are useful for checking
           server response times or for testing network latency.
1 Like

Hi Corona688,

Thanks for your help on Wget.

my expectation :

1) If 1st try is failed and iam retrying again before 2nd retry i have to check for "xxxxxxx" entry in the log file.
2) If "XXXXXXX" entry is not available ,i have to allow 2nd retry.
3) If "XXXXXXX" entry is available,i shouldnot allow to retry again.

Can we check the condition between every retry,if yes please advice me how to achieve this..

thanks in advance.