在bash脚本中循环,直到完成其他任务(从nohup开始)?

时间:2014-01-16 07:49:36

标签: linux bash nohup

我有一个bash脚本,其中几个其他程序是以nohup启动的(所有程序都有相同的可执行文件,但参数不同),例如:

nohup ./code --p0 &
nohup ./code --p1 &
nohup ./code --p2 &

是否可以在nohups调用之后编写while循环,在所有./code运行完成后终止?

1 个答案:

答案 0 :(得分:1)

您似乎在寻找wait

nohup ./code --p0 &
nohup ./code --p1 &
nohup ./code --p2 &
wait    # This would wait for all currently active child processes
echo "This statement would be printed after all nohup calls are finished executing"