我如何等待在Unix中完成命令的执行?

时间:2018-03-21 22:48:24

标签: python bash shell unix csh

我在计算节点中有25个处理器。

我有一个主要的python脚本A a)在循环中运行3)在每个循环中执行20 tasks,这个循环也分布在25个处理器中。

主Python脚本A

Lots of calculations

os.system("csh subtask.csh; wait")

Lots of calculations
Return to beginning of loop

其中,subtask.csh属于这种类型:

./model -h 1 controlfile
./model -h 2 controlfile
./model -h 3 controlfile
./model -h 4 controlfile
./model -h 5 controlfile
... 
./model -h 20 controlfile

但是,这样,我的程序不会等待subtask.csh完成。

我怎样才能让它等待?

1 个答案:

答案 0 :(得分:0)

你可以试试这个吗?

./model -h 1 controlfile &
./model -h 2 controlfile &
./model -h 3 controlfile &
./model -h 4 controlfile &
./model -h 5 controlfile &
wait
相关问题