LSF - Get the ID of a submitted application

Say I'm sending a job using something like bsub pwd . Now I would like to get the job id of this job to build the dependency for the next job. Is there a way to get bsub to return the job id?

+8
lsf
source share
5 answers

As a reference, this is the best solution I could come up with. It uses the fact that bsub writes a string containing an ID to STDOUT.

 function nk_jobid { output=$($*) echo $output | head -n1 | cut -d'<' -f2 | cut -d'>' -f1 } 

Using:

 jobid=$(nk_jobid bsub pwd) 
+5
source share

Niels and Andrew have answers to this particular question in shell and C / C ++ environments, respectively. For the purpose of building dependencies, you can also name your task with -J, and then build the dependency based on the name of the task:

 bsub -J "job1" <cmd1> bsub -J "job2" <cmd2> bsub -w "done(job1) && done(job2)" <cmd> 

Here is a bit more information here .

This also works with job arrays:

 bsub -J "ArrayA[1-10]" <cmd1> bsub -J "ArrayB[1-10]" <cmd2> bsub -w "done(ArrayA[3]) && done(ArrayB[5])" <cmd> 

You can even do phased addiction. The following i-th element of the task will be executed only when the corresponding element in ArrayB reaches the DONE state:

 bsub -w "done(ArrayB[*])" -J "ArrayC[1-10]" <cmd3> 

You can find additional information about various things that you can specify in -w here .

+7
source share

If you use C ++, you can use lsblib , the LSF C API, for submitting jobs. Input and output are structures. In particular, the output structure contains a job identifier.

 #include <lsf/lsbatch.h> LS_LONG_INT lsb_submit (struct submit *jobSubReq, struct submitReply *jobSubReply) 
+4
source share
 $jobid = "0" bsub pwd > $jobid cat $jobid 
0
source share

If you just want to see the JOBID after submitting, most of the time I will just use bhist or bhist -l to view current jobs and details.

 $ bhist Summary of time in seconds spent in various states: JOBID USER JOB_NAME PEND PSUSP RUN USUSP SSUSP UNKWN TOTAL 8664 F14r3 sample 2 0 187954 0 0 0 187956 
0
source share

All Articles