顺序执行批处理作业

时间:2018-07-19 02:23:32

标签: sbatch

我有一个看起来像这样的批处理工作

sbatch --wrap“ perl test.pl file1 file2”

sbatch --wrap“ perl test.pl file3 file4”

sbatch --wrap“ perl test.pl file5 file6”

sbatch --wrap“ perl test.pl file7 file8”

&列表一直持续到

sbatch --wrap“ perl test.pl file49 file50”

如何依次运行各个作业? 谢谢

1 个答案:

答案 0 :(得分:0)

您必须使一个脚本依赖于前一个脚本的完成:

JOBID=$(sbatch --wrap "perl test.pl file1 file2" | awk '{print $4}')
for N in {3..49..2}
do
    JOBID=$(sbatch -d afterok:$JOBID --wrap "perl test.pl file$N file$(($N+1))" | awk '{print $4}')
done

顺便说一句,在注释中建议的singleton方法也是一种很好的方法,它使您摆脱了JobID管理的麻烦。

相关问题