首页 > 解决方案 > 减少 wget 中的失败尝试次数

问题描述

我有一个简单的脚本,它在循环中使用 wget 直到它成功。它最终成功了,但在此之前它失败了很多次,因为它试图联系的服务器已经关闭了一段时间。如何减少我在输出中看到的“连接被拒绝”消息的数量?我尝试使用--waitretryand--wait标志wget来减少 wget 尝试的次数,但我仍然看到许多“连接被拒绝”尝试。

这就是我的 wget 命令的样子:

while :; do wget -T 30 -nc --wait=30 http://193.155.44.23 && break; done

这就是我在输出中看到的:

--2021-07-19 17:52:05--  http://193.155.44.23/
Connecting to 193.155.44.23:80... failed: Connection refused.
--2021-07-19 17:52:05--  http://193.155.44.23/
Connecting to 193.155.44.23:80... failed: Connection refused.
--2021-07-19 17:52:05--  http://193.155.44.23/
Connecting to 193.155.44.23:80... failed: Connection refused.
--2021-07-19 17:52:05--  http://193.155.44.23/
Connecting to 193.155.44.23:80... failed: Connection refused.
--2021-07-19 17:52:05--  http://193.155.44.23/
Connecting to 193.155.44.23:80... failed: Connection refused.
--2021-07-19 17:52:05--  http://193.155.44.23/
Connecting to 193.155.44.23:80... failed: Connection refused.


(repeated many many times)

标签: bashnetwork-programmingwget

解决方案


推荐阅读