如果没有回应,BASH会杀死wget

Adr*_*ian 1 linux bash wget

我有这个代码

...
SERVERCONNECTION=$(wget --quiet -O - http://xx:yy@127.0.0.1:10001/server | grep connections | awk '{print $36}')

有时url得到响应,然后我想杀死wget进程并将SERVERCONNECTIION变量设置为0.

vto*_*nen 5

使用--timeout=seconds,即设置wget进程的超时

SERVERCONNECTION=$(wget --timeout=5 --quiet -O - http://xx:yy@127.0.0.1:10001/server | grep connections | awk '{print $36}')
Run Code Online (Sandbox Code Playgroud)