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

2024-05-14 07:08:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我有25个处理器在一个计算节点。你知道吗

我有一个python主脚本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完成。你知道吗

我怎样才能让它等待?你知道吗


Tags: of脚本modelreturn节点os处理器system
1条回答
网友
1楼 · 发布于 2024-05-14 07:08:44

你能试试这个吗??你知道吗

./model -h 1 controlfile &
./model -h 2 controlfile &
./model -h 3 controlfile &
./model -h 4 controlfile &
./model -h 5 controlfile &
wait

相关问题 更多 >

    热门问题