Job Dependencies under LSF


There may be situations where there are obvious dependencies between jobs, and one cannot start before another has finished (for example because it is dependent on the results of the previous jobs).

LSF provides a dependency feature that can be used for this purpose. One can therefore specify in the batch script of a job, that this job has a dependency on another one. This is done with the syntax

#BSUB -w "done(<jobid>)"

This will ensure that the current job is started only after the job with the corresponding jobid is completed successfully. Some of the most common options are

done : job state done
ended : job state exit or done
exit : job state is EXIT and eventually with a specific exit code exit(<jobid>,<exit-code>)
started : job state DONE, EXIT, USUSP, SSUSP or RUN

In case of a job array, the array-id can also be specified with the syntax

#BSUB -w "done(<jobid>[job-index])"

To know the jobs that a job depends on, type

bjdepinfo <jobid>

To show the jobs that depend on a job, use the -c oprion

bjdepinfo -c <jobid>

NOTE:

  • More complex expressions are possible, combining options (multiple dependencies) with the logical operators &&, ||, and !;
  • man bjdepinfo for more options