Job Dependencies

Job dependencies - SLURM

A job can be given the constraint that it only starts after another job has finished.

In the following example, we have two Jobs, A and B. We want Job B to start after Job A has successfully completed.

First we start Job A by submitting it via sbatch:

$ sbatch <jobA.sh>

Making note of the assigned job ID for Job A, we then submit Job B with the added condition that it only starts after Job A has successfully completed:

$ sbatch --dependency=afterok:<jobID_A> jobB.sh

If we want Job B to start after several other Jobs have completed, we can specify additional jobs, using a ':' as a delimiter:

$ sbatch --dependency=afterok:<jobID_A:jobID_C:jobID_D> jobB.sh

We can also tell slurm to run Job B, even if Job A fails, like so:

sbatch --dependency=afterany:<jobID_A> jobB.sh

For more information, consult the man page for sbatch.

Updated: 2024-03-08, 14:54