- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
您希望此命令在退出前需要多长时间?
wget --timeout=1 --tries=2 "http://www.google.com:81/not-there"
我希望超时为 1 秒,2 次尝试意味着 2 秒,但它需要 6.025 秒
wget --timeout=1 --tries=2 "http://www.google.com:81/not-there"
--2017-04-27 16:49:12--http://www.google.com:81/not-there
Resolving www.google.com (www.google.com)... 209.85.203.105, 209.85.203.103, 209.85.203.99, ...
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:4009:80d::2004|:81... failed: Network is unreachable.
我不知道为什么它在退出前尝试了 6 次。
tries
好像是重试。如果我设置 --retry-connrefused
它至少会重试,但所花费的总时间仍然不是我所期望的。我希望能够决定在超时时应该尝试多少次。
编辑:
在@Socowi 的建议下,我尝试将 waitretry 与 retry-connrefused 结合使用并得到相同的行为:
$ wget --timeout=1 --waitretry=0 --tries=2 --retry-connrefused "http://www.google.com:81/not-there"
--2017-04-27 20:29:47-- http://www.google.com:81/not-there
Resolving www.google.com (www.google.com)... 2a00:1450:400b:c00::68, 209.85.203.99, 209.85.203.147, ...
Connecting to www.google.com (www.google.com)|2a00:1450:400b:c00::68|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Retrying.
--2017-04-27 20:29:54-- (try: 2) http://www.google.com:81/not-there
Connecting to www.google.com (www.google.com)|2a00:1450:400b:c00::68|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Giving up.
编辑二
当两个相同的命令表现不同时,我真的很困惑。
root@8c59d6dd05fe:/var/www/html# wget --timeout=1 --waitretry=0 --tries=2 --retry-connrefused "http://www.google.com:81/not-there"
converted 'http://www.google.com:81/not-there' (ANSI_X3.4-1968) -> 'http://www.google.com:81/not-there' (UTF-8)
--2017-04-27 19:50:28-- http://www.google.com:81/not-there
Resolving www.google.com (www.google.com)... 216.58.211.164, 2a00:1450:4009:805::2004
Connecting to www.google.com (www.google.com)|216.58.211.164|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:4009:805::2004|:81... failed: Cannot assign requested address.
Retrying.
--2017-04-27 19:50:29-- (try: 2) http://www.google.com:81/not-there
Connecting to www.google.com (www.google.com)|216.58.211.164|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:4009:805::2004|:81... failed: Cannot assign requested address.
Giving up.
root@8c59d6dd05fe:/var/www/html# wget --timeout=1 --waitretry=0 --tries=2 --retry-connrefused "http://www.google.com:81/not-there"
converted 'http://www.google.com:81/not-there' (ANSI_X3.4-1968) -> 'http://www.google.com:81/not-there' (UTF-8)
--2017-04-27 19:50:35-- http://www.google.com:81/not-there
Resolving www.google.com (www.google.com)... 209.85.203.104, 209.85.203.147, 209.85.203.106, ...
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:400b:c03::68|:81... failed: Cannot assign requested address.
Retrying.
--2017-04-27 19:50:41-- (try: 2) http://www.google.com:81/not-there
Connecting to www.google.com (www.google.com)|209.85.203.104|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.147|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.106|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.103|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.105|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|209.85.203.99|:81... failed: Connection timed out.
Connecting to www.google.com (www.google.com)|2a00:1450:400b:c03::68|:81... failed: Cannot assign requested address.
Giving up.
我以为我有点疯狂,但只有当@Socowi 在评论中指出每次重试的 IP 不同时,它才会点击。这取决于返回的可能 IP 的数量。我看到的神奇数字 7(重试)是 IP 选项的编号。当我只选择一个特定的 IP 时,它只会尝试一次。
最佳答案
您的 wget 似乎将 URL 解析为多个 IP 地址,如 wget
的第二行所示的输出。然后使用指定的超时测试每个 IP。不幸的是,我没有找到任何选项来将 DNS 查找限制到一个地址或为所有 IP 一起设置总超时。但是你可以尝试使用 "<googles ip address>:81/not-there"
而不是域名。
自动将域解析为您可以使用的单个 IP 地址
wget "http://$(getent hosts www.google.com | sed 's/ .*//;q'):81/not-there"
如您所知,设置 --retry-connrefused
让wget
即使在 »连接被拒绝« 错误后重试。指定的超时用于每次重试,但在重试之间会有一个暂停,每次重试后暂停时间会变长。
wget --timeout=1 --tries=5 --retry-connrefused URL
做类似的事情
try to connect for 1 second
failed -> wait 1 second
try to connect for 1 second
failed -> wait 2 seconds
try to connect for 1 second
failed -> wait 3 second
try to connect for 1 second
failed -> wait 4 second
try to connect for 1 second
因此该命令需要 tries * timeout + 1 + 2 + ... + (tries - 1)
秒。此行为在 man wget
中指定在选项下,它允许您更改它:)
--waitretry=seconds
If you don't want Wget to wait between every retrieval, but onlybetween retries of failed downloads, you can use this option. Wgetwill use linear backoff, waiting 1 second after the first failureon a given file, then waiting 2 seconds after the second failure onthat file, up to the maximum number of seconds you specify.By default, Wget will assume a value of 10 seconds.
我想你想用类似的东西
wget --timeout=1 --waitretry=0 --tries=5 --retry-connrefused URL
这消除了两次重试之间的停顿,导致总时间为 timeout * tries
.
关于linux - wget 一起使用 --timeout 和 --tries,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43662591/
如果我从命令行使用 wget 而不指定显式用户代理,我想知道传递的默认用户代理是什么。 我有一些基于用户代理更改输出的代码。 wget http://www.google.com -O test.ht
我想使用 wget 下载网络,但为了使它更像一个真正的用户,我想在请求之间进行小的随机延迟。 我正在通过 cmd 执行 wget。 最佳答案 您可以将以下代码添加到命令行中,这会在服务器请求之间增加
我想从 ftp 服务器下载许多文件(大约 10000 个)。文件名太长。我只想用名称中的日期保存它们。例如:ABCDE201604120000-abcde.nc 我更喜欢20160412.nc可能吗?
我想抓取一个网站来构建它的站点地图。 问题是,该站点使用 htaccess 文件来阻止蜘蛛,因此以下命令仅下载主页(index.html)并停止,尽管它确实包含指向其他页面的链接: wget -mkE
当我去ISC时here要下载 BIND,我的浏览器会自动正确保存下载的文件。例如,如果我点击 9.9.4-P2 的下载按钮,它会弹出一个窗口,如果我点击右侧的“BIND 9.9.4-P2 - tar.
我的 shell 脚本中有一个像这样的 wget 命令: reponse="`wget -O- http:localhost:8080/app/index.html`" 我不明白 -O- 选项。我被解
我正在尝试使用Wget下载页面,但我无法通过登录屏幕。 如何使用登录页面上的发布数据发送用户名/密码,然后以经过身份验证的用户身份下载实际页面? 最佳答案 基于手册页: # Log in to the
我创建了指向框中文件的直接链接: 上一个链接是浏览器网络界面,所以我随后分享了一个直接链接: 但是,如果我使用 wget 下载文件,我会收到垃圾。 如何使用 wget 下载文件? 最佳答案 我可以通过
我尝试了“-N”和“--no-clobber”,但我得到的唯一结果是检索现有 example.exe 的新副本,其编号是使用此语法“example.exe.1”添加的数字'。这不是我想要得到的。我只需
当我执行 wget 时,我希望文件系统中保存的文件具有现在的保存日期。不是服务器的日期。当我这样做时: ll -ltr 我首先下载了文件(列表中的最后一个)。 以及如何将其设为默认值?什么时候是默认值
在我的 CentOS 6.5 中,我想安装 wget: # yum -y install wget 但我收到以下错误: [root@localhost yum.repos.d]# yum -y i
我正在尝试使用 wget 抓取网站。这是我的命令: wget -t 3 -N -k -r -x -N 表示“如果服务器版本低于本地版本,则不下载文件”。但这不起作用。当我重新启动上述抓取操作时,会一遍
我在 cron 作业中使用 wget 每分钟将 .jpg 文件提取到 Web 服务器文件夹中(每次使用相同的文件名,覆盖)。此文件夹是“事件的”,因为 Web 服务器也从那里提供该图像。但是,如果有人
我有以下问题。我需要镜像受密码保护的站点。听起来很简单: wget -m -k -K -E --cookies=on --keep-session-cookies --load-cookies=myC
我可以使用 wget 检查 404 错误而不实际下载资源吗?如果是这样怎么办?谢谢 最佳答案 命令行参数--spider正是用于此目的。在此模式下,wget 不会下载文件,如果找到资源,则返回值为零;
我正在通过 wget 下载一些 .mp3 文件(全部合法): wget -r -nc files.myserver.com 有时我必须停止下载,此时文件已部分下载。例如,10 分钟的 record.m
我正在使用 wget 连接到这样的安全站点: wget -nc -i inputFile 其中 inputeFile 由这样的 URL 组成: https://clientWebsite.com/Th
我目前正在使用一个相当复杂的 wget 命令,但它的本质是 -p 和 -k 标志来下载所有先决条件。如何将主要下载文件重命名为 index.html? 比如我下载一个网页 http://myaweso
这看起来应该很简单,但我无法弄清楚。我要发wget类似于以下的请求, wget http://www.foo.com/bar.cgi?param=\"p\" 但我不希望它对引号(或其他任何东西)进行
我正在编写一个需要从 sourceforge 下载发布文件的脚本。如何获得好的链接? 同样的问题及其答案于 2013 年在此处给出,但不再有效。 https://unix.stackexchange.
我是一名优秀的程序员,十分优秀!