shell 并发运行

shell 之并发:

shell并发之间是进程
sh 1.sh & 2.sh

普通并发

#!/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

猜你喜欢

转载自blog.csdn.net/qq_40393187/article/details/88884110