Use slurm job id

2019-02-02 09:40发布

When I launch a computation on the cluster, I usually have a separate program doing the post-processing at the end :

sbatch simulation
sbatch --dependency=afterok:JOBIDHERE postprocessing

I want to avoid mistyping and automatically have the good job id inserted. Any idea? Thanks

1条回答
爷的心禁止访问
2楼-- · 2019-02-02 10:25

You can do something like this:

RES=$(sbatch simulation) && sbatch --dependency=afterok:${RES##* } postprocessing

The RES variable will hold the result of the sbatch command, something like Submitted batch job 102045. The construct ${RES##* } isolates the last word (see more info here), in the current case the job id. The && part ensures you do not try to submit the second job in the case the first submission fails.

查看更多
登录 后发表回答