10

With Platform LSF, is there a command that will wait for either a specific job or all my submitted jobs to finish before returning? In other words, I am looking for the LSF equivalent of the wait built-in command in bash.

2 Answers 2

10

If you give the -K option to bsub, it will wait for the job to complete before returning. You can then background several bsub commands in the shell and use the shell's wait command to wait for them. Example:

#!/bin/bash
bsub -K -o out.1 sleep 10 &
bsub -K -o out.2 sleep 5 &
wait
1
  • 2
    -K flag doesn't work if the bsub job is an array
    – par
    Mar 23, 2017 at 12:30
4

bwait

Example:

bsub -J 'myjobname' -o bsub.log bash -c 'date && sleep 10'
bwait -w 'ended(myjobname)'

The bwait waits until the corresponding bsub finished.

The same method also works for jobs arrays where -K is not supported:

bsub -J 'myjobname[1-40]' -o 'bsub%I.log" 'sleep $JOBINDEX && echo $JOBINDEX'
bwait -w 'ended(myjobname)'

Besides ended() there is also done() and exit(), which make bwait only exit successfully if the exit status is 0 or not 0 respectively, and otherwise fail with:

Wait condition is never satisfied

because LSF has different job states for both cases.

Related documentation:

bsub -I

This is another good alternative to -K if you only have one job. E.g.:

bsub -I 'echo a;sleep 1;echo b;sleep 1;echo c'
echo done

prints stdout live to the terminal, and only runs echo done once the job finishes.

Documented at: https://www.ibm.com/docs/en/spectrum-lsf/10.1.0?topic=options-i

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .