我使用一个工具来监控网页是否已经启动和运行。
该工具在内部使用curl命令来获取输出。
然而,当一个网页需要更长的时间来响应时,它会返回一个TIMEOUT错误。我不可能增加工具的超时。
有任何方法来设置/修改网页响应的超时时间吗?
有什么可以修改的变量吗?
发布于 2014-08-07 09:43:06
您可以使用-m选项:
-m, --max-time <seconds>
Maximum time in seconds that you allow the whole operation to
take. This is useful for preventing your batch jobs from hang‐
ing for hours due to slow networks or links going down. See
also the --connect-timeout option.
If this option is used several times, the last one will be used.这包括连接的时间,如果要单独指定它,请使用--connect-timeout选项。
发布于 2014-08-07 09:44:57
通常,在调用curl时,您会在命令行上使用一个选项来执行此操作。但是,由于您无法更改这一点,还有另一种方法--您可以为curl创建一个配置文件。在unix上,curl将首先查看运行curl的用户的主目录,该目录中有一个名为.curlrc的文件。用行创建该文件
connect-timeout = 10将超时时间缩短到10秒。也可以通过选项max-time为整个操作设置最大时间:
max-time = 10发布于 2014-08-07 09:44:29
curl有一个“连接超时”选项:
--connect-timeout <seconds>如果你的“工具”是一个脚本,你可以手动编辑到那里。但是https://unix.stackexchange.com/a/148926/77959甚至更好-编辑config!
https://unix.stackexchange.com/questions/148922
复制相似问题