【发布时间】:2020-01-19 23:53:44
【问题描述】:
还有一个 nube 的问题.. 我有一个脚本,它正在逐一检查列表中的主机以获取 http 响应。如何使用 xargs 或其他方法将其升级为 multitrhead?
#!/bin/bash
response="200"
cat list.txt | while read string
do
test=$(curl -I --path-as-is -s -k "http://"$string"/index.html" | head -n1)
if grep -q "response" <<< "$test"; then
echo $string " has response " $response
fi
done
【问题讨论】:
-
如果您有最新版本的 curl (7.66+),您可以使用
--paralleland--parallel-max命令行选项来执行多个并行请求。 (在我撰写此评论(2020 年 1 月)时,您可能没有足够新的版本,因为 stable Debian package 目前是 v7.64。但将来此功能将更广泛地使用。