方法1:
#!/bin/bash c=0 for i in `seq -w 18 31`;do while [ $c -ge 3 ];do c=$(jobs -p |wc -w) sleep 1s done bash run_cal_us_tmp.sh 201407$i & #echo "`sleep 5s`haha" & c=$(jobs -p |wc -w) done
优点:实现简单
缺点:若sleep 时间较短,性能开销大。
方法2:
#/bin/bash -x SPEED=50 mkfifo tmpfifo exec 6<>tmpfifo for(( i=0;i<5;i++ )); do echo $i; done >&6 while read tmp<&6 do echo "haha" done wait exec >&6-
时间: 2024-12-30 21:38:04