LSF - Get ID of submitted job

后端 未结 5 906
予麋鹿
予麋鹿 2021-01-04 12:16

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

相关标签:
5条回答
  • 2021-01-04 12:29

    Just as a reference, this is the best solution I could come up with so far. It takes advantage of the fact that bsub write a line containing the ID to STDOUT.

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

    Usage:

    jobid=$(nk_jobid bsub pwd)
    
    0 讨论(0)
  • 2021-01-04 12:41

    In case you are using C++, you can use the lsblib, LSF C API to submit jobs. The input and the output are structs. In particular, the output struct contains the job id.

    #include <lsf/lsbatch.h>    
    LS_LONG_INT lsb_submit (struct submit *jobSubReq, struct submitReply *jobSubReply)
    
    0 讨论(0)
  • 2021-01-04 12:42

    If you just want to view the JOBID after submission, most of the time I will just use bhist or bhist -l to view the running 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 讨论(0)
  • 2021-01-04 12:45

    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" <cmd1>
    bsub -J "job2" <cmd2>
    bsub -w "done(job1) && done(job2)" <cmd>
    

    There's a bit more info 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 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]" <cmd3>
    

    You can find more info on the various things you can specify in -w here.

    0 讨论(0)
  • 2021-01-04 12:49
    $jobid = "0"
    bsub pwd > $jobid
    cat $jobid
    
    0 讨论(0)
提交回复
热议问题