Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does WGET timeout?

Tags:

linux

cron

wget

I'm running a PHP script via cron using Wget, with the following command:

wget -O - -q -t 1 http://www.example.com/cron/run 

The script will take a maximum of 5-6 minutes to do its processing. Will WGet wait for it and give it all the time it needs, or will it time out?

like image 500
Ali Avatar asked Feb 18 '10 19:02

Ali


People also ask

What is the default timeout for wget?

As per wget anyay you should not change its timeout, according to the UNIX manual the default wget timeout is 900 seconds (15 minutes), whis is much larger that the 5-6 minutes you need.

What can I use instead of wget?

The best alternative is aria2, which is both free and Open Source. Other great apps like Wget are uGet, cURL, ArchiveBox and HTTPie. Wget alternatives are mainly Download Managers but may also be Website Downloaders or HTTP Clients.

What happens with wget?

Wget has been designed for robustness over slow or unstable network connections. If a download does not complete due to a network problem, Wget will automatically try to continue the download from where it left off, and repeat this until the whole file has been retrieved.

How does wget command work?

wget is designed for robustness over slow or unstable network connections; if a download fails due to a network problem, it keeps retrying until the whole file is retrieved. If the server supports regetting, it instructs the server to continue the download from where it left off.


2 Answers

According to the man page of wget, there are a couple of options related to timeouts -- and there is a default read timeout of 900s -- so I say that, yes, it could timeout.


Here are the options in question :

-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.


And for those three options :

--dns-timeout=seconds 

Set the DNS lookup timeout to seconds seconds.
DNS lookups that don't complete within the specified time will fail.
By default, there is no timeout on DNS lookups, other than that implemented by system libraries.

--connect-timeout=seconds 

Set the connect timeout to seconds seconds.
TCP connections that take longer to establish will be aborted.
By default, there is no connect timeout, other than that implemented by system libraries.

--read-timeout=seconds 

Set the read (and write) timeout to seconds seconds.
The "time" of this timeout refers to idle time: if, at any point in the download, no data is received for more than the specified number of seconds, reading fails and the download is restarted.
This option does not directly affect the duration of the entire download.


I suppose using something like

wget -O - -q -t 1 --timeout=600 http://www.example.com/cron/run 

should make sure there is no timeout before longer than the duration of your script.

(Yeah, that's probably the most brutal solution possible ^^ )

like image 69
Pascal MARTIN Avatar answered Oct 07 '22 10:10

Pascal MARTIN


The default timeout is 900 second. You can specify different timeout.

-T seconds --timeout=seconds 

The default is to retry 20 times. You can specify different tries.

-t number --tries=number 

link: wget man document

like image 37
hIpPy Avatar answered Oct 07 '22 09:10

hIpPy