SLURM allows you to define different kind of dependencies between jobs, for instance to make sure that certain jobs will run only if another job succeeded/failed. The dependencies can be added to your job script using the following line:
#SBATCH --dependency=type:jobid1:jobid2:jobidN,type:jobid1:jobid2:jobidN,...
The job id should belong to an already submitted job, while type should be one of the following:
Type | Meaning |
after | Start this job after the specified jobs have started |
afterany | Start this job after the specified jobs have completed |
afternotok | Start this job after the specified jobs have failed |
afterok | Start this job after the specified jobs have successfully completed |
expand | Use this job allocation to expand the job allocation of the specified job (just one, must be in the same partition and have a similar wall clock time) |
singleton | Start this job after all previously submitted jobs with the same name have completed |
$ sbatch jobscript.sh Submitted batch job 12345 $ sbatch jobscript.sh Submitted batch job 12346 $ sbatch --dependency=afterok:12345:12346 jobscript.sh Submitted batch job 12347