WGET 是否超时? [英] Does WGET timeout?

查看:62
本文介绍了WGET 是否超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Wget 通过 cron 运行 PHP 脚本,命令如下:

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

该脚本最多需要 5-6 分钟来进行处理.WGet 会等待它并给它所有需要的时间,还是会超时?

解决方案

根据 wget 的手册页,有几个与超时相关的选项——默认读取超时为 900 秒——所以我说,是的,它可能会超时.


以下是相关选项:

-T 秒--超时=秒

<块引用>

将网络超时设置为秒秒.这相当于指定 --dns-timeout,--connect-timeout, 和--read-timeout,都一样时间.


对于这三个选项:

--dns-timeout=seconds

<块引用>

将 DNS 查找超时设置为秒秒.
没有的DNS查找在规定时间内完成将失败.
默认情况下,没有DNS 查找超时,除了由系统库实现.

--connect-timeout=seconds

<块引用>

将连接超时设置为秒秒.
TCP 连接需要更长的建立将被中止.
默认没有连接超时,除了实现通过系统库.

--read-timeout=seconds

<块引用>

将读取(和写入)超时设置为秒秒.
时间"这个超时是指空闲时间:如果,在下载的任何时候,没有数据收到超过指定的秒数,读数失败并重新启动下载.
这个选项不直接影响整个持续时间下载.


我想使用类似

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

应确保在超过脚本持续时间之前没有超时.

(是的,这可能是最残酷的解决方案^^)

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?

解决方案

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 ^^ )

这篇关于WGET 是否超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆