Skip to Main Content

Information Technology Services

University of Hawaii System

SLURM Job Dependencies

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 its submit script via sbatch:

$ sbatch

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: 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: jobB.sh

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

sbatch --dependency=afterany: jobB.sh