📌  相关文章
📜  启动多个 bash 进程并等待所有进程完成 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:50:16.382000             🧑  作者: Mango

代码示例1
#!/bin/bash

FAIL=0

echo "starting"

./sleeper 2 0 &
./sleeper 2 1 &
./sleeper 3 0 &
./sleeper 2 0 &

for job in `jobs -p`
do
echo $job
    wait $job || let "FAIL+=1"
done

echo $FAIL

if [ "$FAIL" == "0" ];
then
echo "YAY!"
else
echo "FAIL! ($FAIL)"
fi