Search code examples
lsf

LSF - Get ID of submitted job


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 way I can get bsub to return the job ID?


Solution

  • 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)