Say I submit a job using something like bsub pwd
. Now I would like to get the job ID of that job in order to build a dependency for the next job. Is there some
Nils and Andrey have the answers to this specific question in shell and C/C++ environments respectively. For the purposes of building dependencies, you can also name your job with -J then build the dependency based on the job name:
bsub -J "job1"
bsub -J "job2"
bsub -w "done(job1) && done(job2)"
There's a bit more info here.
This also works with job arrays:
bsub -J "ArrayA[1-10]"
bsub -J "ArrayB[1-10]"
bsub -w "done(ArrayA[3]) && done(ArrayB[5])"
You can even do element-by-element dependency. The following job's i-th element will only run when the corresponding element in ArrayB
reaches DONE
status:
bsub -w "done(ArrayB[*])" -J "ArrayC[1-10]"
You can find more info on the various things you can specify in -w
here.