Wait for one or all LSF jobs to complete

8

1

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.

Vebjorn Ljosa

Posted 2009-09-24T16:16:51.623

Reputation: 1 441

Answers

7

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

Vebjorn Ljosa

Posted 2009-09-24T16:16:51.623

Reputation: 1 441

2-K flag doesn't work if the bsub job is an array – par – 2017-03-23T12:30:08.420

2

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:

Ciro Santilli 新疆改造中心法轮功六四事件

Posted 2009-09-24T16:16:51.623

Reputation: 5 621