LSF::JobManager - submit and wait for a set of LSF Jobs


    use LSF RaiseError => 0, PrintError => 1, PrintOutput => 0;
    use LSF::JobManager;

    my $m = LSF::JobManager->new(-q=>'small');

    my $job = $m->submit("echo hello");
    $m->submit("echo world");
    for my $job ($m->jobs){
    $m->wait_all_children( history => 1 );
    print "All children have completed!\n";

    for my $job ($m->jobs){ # much quicker if history is pre-cached
        print STDERR "$job exited non zero\n" if $job->history->exit_status != 0;
    $m->clear; # clear out the job manager to reuse.


LSF::JobManager provides a simple mechanism to submit a set of command lines to the LSF Batch system and then wait for them all to finish in a blocking (efficient) manner.




new ( [ ARGS ] )

$manager = LSF::JobManager->new(-q=>'small' ,-m=>'mymachine');

Creates a new LSF::JobManager object.

Any parameters are used as defaults passed to the submit method.


$manager->submit( [ [ ARGS ] ], [CMD] )

Submits a command line to LSF. This is a wrapper around the LSF::Job->submit call. The required argument is the command line to submit. Optional arguments override the defaults given to new. The submitted LSF::Job object is returned on success, otherwise undef is returned, $? and $@ set. See LSF::Job

$manager->wait_all_children( [ depend => DEPENDANCY, history => 1 ] )

Waits for all previously submitted LSF Jobs to complete in a blocking manner.

If a dependancy expression is provided then this is used in preference to an autogenerated dependancy based on the job id's of all the submitted jobs. In conjunction with named jobs ( the -J flag ) this can be used to get around the shell arg length limit which can be hit by extremely long dependancy expressions. See the bsub documentation for details of job names and depenancy expressions.

If the history flag is used to pass a true value then after all jobs have completed the history of each job is fetched in batch. It is much quicker this way than fetching each job history separately. The time taken is still significant however. If you do not intend to check the exit status or the command line or any other property of the Job::History object then it is worth passing a false value and avoiding the overhead.

$manager->params( [ [ PARAMS ] ] )

Sets the default submission parameters.


Returns an array of the submitted LSF::Job objects.


Empties the job array so that the manager can be reused. Returns an array of the jobs removed.


The LSF::Batch module on cpan didn't compile easily on all platforms i wanted. The LSF API didn't seem very perlish either. As a quick fix I knocked these modules together which wrap the LSF command line interface. It was enough for my simple usage. Hopefully they work in a much more perly manner.




Mark Southern (


Copyright (c) 2002, Merck & Co. Inc. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see

1 POD Error

The following errors were encountered while parsing the POD:

Around line 244:

You forgot a '=back' before '=head1'