Skip to content

Job Dependencies

This pages describes the SLURM depencency feature. This feature is used when you need to chain jobs, due to dependencies. For example:

  • a preprocessing job with 1 core should be followed by a simulation with 40 cores. Results should be post processed with a single core job.
  • a post processing job should be submitted after all tasks of a job array are finished


The follow-up job need to specify the dependency using the sbatch option --dependency=<type>:<listOfJobIDs>. The type can be after, afterok, afterany, afternotok, aftercorr, expand, singleton. (see man sbatch for more info).

The underlying job (which this job depends on) need to be submitted first. The related job ID can be caught, by collecting the sbatch output with the --parsable option, e.g.

jid_w01=$(sbatch --parsable


A pipeline should be build with: - preparation: - 2 worker jobs ( and - if successfull: a collector job ( - otherwise: a handling the error job ( - The following script would submit all 3 job with respect to their dependencies.

jid_pre=$(sbatch --parsable
jid_w01=$(sbatch --parsable --dependency=afterok:${jid_pre}
jid_w02=$(sbatch --parsable --dependency=afterok:${jid_pre}
sbatch --dependency=afterok:${jid_w01}:${jid_w02}
sbatch --dependency=afternotok:${jid_w01}:${jid_w02}

Dependency on array job

When specifying a dependency to an array job only one job ID need to be specified, no matter how many array tasks are included.

Thus, a 100 task array job and a postprocessing job can be launched using:

jid=$(sbatch --parsable --array=1-100
sbatch --dependency=afterok:${jid}
Where the postprocessing job only runs if all 100 array task ended without error.