惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
A
About on SuperTechFans
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
IT之家
IT之家
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
B
Blog RSS Feed
H
Help Net Security
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
L
LangChain Blog
Vercel News
Vercel News

博客园 - toong

Kubernetes AI Gateway Kind 归属地图 kubuntu通过flatpak安装软件 ai-gateway 安装记录 家用台式工作站软件配置 envoy DDOS HTTP/2 Bomb CVE-2026-47774 安全漏洞分析 P2P与FRP与websocket python运行虚拟化环境 大模型从0到1 绑定网卡中断后是否需要设置RFS linux socket reuse port 小测试 现代C++ envoy timeout 说明 观察中断的脚本 /proc/interrupts openssl查看编译时选项设置的方法 内核ipsec转发优化方法 提高ipsec多核并行能力的优化方法之一 tc qdisc 的burst如何设置 bash模拟netstat取值的脚本 linux内核对MSI网卡队列的smp_affinity亲和CPU选择 bash单例模式 linux 分析中断 linux 查看 ipsec 丢包 linux内核rps与rfs机制分析 linux获取CPU利用率的快捷命令 开启openssl legacy的方法
bash多并发--进程池数量控制
toong · 2025-07-11 · via 博客园 - toong
function ping_target()
{
        local target=$1
        timeout 0.5 ping $target -c 1 > /dev/null
        if [ "$?" == "0" ]
        then
                echo "ping succ: $target" >> "$RESULT_FILE"
        else
                echo "ping failed: $target" >> "$RESULT_FILE"
        fi
}

count_all=0
count_fail=0
count_succ=0

MAX_CONCURRENT=50
current_jobs=0
truncate -s0 "$RESULT_FILE"
while read line
do
        count_all=`expr $count_all + 1`
        ping_target $line &

        while ((current_jobs >= MAX_CONCURRENT))
        do
                current_jobs=$(pstree -p $$ |wc -l)
                sleep 0.1
        done
done <<< "$list"

wait

count_succ=$(grep -c "succ" "$RESULT_FILE")
count_fail=$(grep -c "failed" "$RESULT_FILE")
total=$(wc -l < "$RESULT_FILE")

posted on 2025-07-11 17:39  toong  阅读(13)  评论()    收藏  举报