阻止shell脚本的执行流程直到先前的进程完成?

时间:2013-03-23 00:04:42

标签: shell scripting

我有一个我希望并行运行的作业列表,我从一个主脚本中调用它们。这是一个例子

echo "Starting jobs"
job1 &
job2 &
job3 &

# I want to wait until job1, job2 & job3 finishes on the multi core box
echo "Now I can proceed"

我该怎么做?

1 个答案:

答案 0 :(得分:4)

wait是命令。执行将不会等到作业完成后再等待。

echo "Starting jobs"
job1 &
job2 &
job3 &

wait

# I want to wait until job1, job2 & job3 finishes on the multi core box
echo "Now I can proceed"