How to make sbatch job run after a previous one has completed?
Asked Answered
E

1

11

I was provided two sbatch scripts to submit and run. The input of the second one is based on the output of the first one. The assignment I need to do this for simply tells us to check on the first one every few hours or so and then to submit the second one after it's finished, but is there a way to automate that so the second one runs right after the first is complete? I've already submitted the first one, and it's currently sitting in the queue.

Egoism answered 7/3, 2020 at 23:48 Comment(1)
Check the sbatch documentation for dependencies.Boehike
S
15

The sbatch command has a --dependency option:

-d, --dependency= Defer the start of this job until the specified dependencies have been satisfied completed.

Submit the first one with

JOBID1=$(sbatch --parsable <other_options> <submission_script>)

and the dependent one with

sbatch --dependency=afterok:$JOBID1

This will make sure the second one only starts after, and only if, the first on completes successfully.

Shoddy answered 12/3, 2020 at 12:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.