如果没有响应,BASH 杀死 wget
我有这个代码
...
SERVERCONNECTION=$(wget --quiet -O - http://xx:[电子邮件受保护]:10001/server | grep 连接 | awk '{print $36}')
有时 url 没有响应,那么我想终止 wget 进程并将 SERVERCONNECTIION 变量设置为 0。
I have this code
...
SERVERCONNECTION=$(wget --quiet -O - http://xx:[email protected]:10001/server | grep connections | awk '{print $36}')
Sometimes the url get inresponsive, then I want to kill wget process and set SERVERCONNECTIION variable to 0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
--timeout=seconds
为wget进程设置超时,即Set a timeout for the wget process with
--timeout=seconds
, i.e.grep 的另一个无用用途。
使用
awk '/connections/ {print $36}'
代替,以便整行读取Another useless use of grep.
Use
awk '/connections/ {print $36}'
instead, so that the whole line reads