shell 之并发:
普通并发
#!/bin/bash
while read line
do
{
command 1
} &
done
command2
如若command2需要用到command1的结果
#!/bin/bash
while read line
do
{
command 1
} &
done
wait
command2
shell脚本的并发控制:
限制进程数
#!/bin/bash
while read line
do
{
joblist=($(jobs -p))
while (( $ {#joblist[*]} >= 20 ))
do
{
sleep 1
joblist=($(jobs -p))
}
done
sleep 10 &
}
done