LSF_ Job Run

Submit jobs through bsub s

The bsub command submits the job to the LSF batch dispatch queue.
Submit a sleep job to the default queue (normal)

% bsub sleep 60
Job <3616> is submitted to default queue <normal>.

When a job is submitted, a unique job id is generated, such as 3616 above.
Queues submitted by tasks can be specified through the -q parameter:

% bsub -q short sleep 60
Job <3628> is submitted to queue <short>.

Job output

By default, when the job is completed, the LSF sends an e-mail with the job report and any output and error messages to the user account submitting the job. You can choose to save the standard output and standard errors to a file using the -o and -e options.
The following commands write the standard output and standard error output of a job to a specific file in the user's home directory:

% bsub -q short -o /home/user1/job/output.%J -e /home/user1/job/errors.%J ls -l
Job <3640> is submitted to queue <short>.

The%J variable represents the jobID and helps you find the output of a particular job through%J.

Bsub-I Interactive Batch Job

Submit an interactive job to the LSF using the -I parameter:
The following command submits an interactive job and displays the output of the ls command:

% bsub -I ls

Submit interactive jobs to be terminals using parameter-Ip.
Submit interactive jobs to pseudo-terminals that support shell s using the parameter-Is.

Show job status

View the job ID and other job information through bjobs, and update the status of each LSF job periodically.

% bjobs
1266  user1     RUN   normal    hosta       hostb       sleep 60    Jun 5 17:39:58

The status of the specified job can be monitored through the job ID.
If all hosts are in the busy state, job will not execute immediately and will be in the pend state in the STAT column.

Use bstop, bresume, and bkill to control job execution

Suspend (bstop), resume (bresume), and kill (bkill) operations using LSF commands.


% bstop 1266
Job <1266> is being stopped 

The job is stopped while it is running and the job status is USUSP through bjobs.

% bjobs
1266  user1     USUSP normal    hosta       hostb       sleep 60    Jun 5 17:39:58

The owner of a job can only suspend his or her own job, and the lsf administrator can suspend all jobs.


Use the command bresume to restore a pending job.

% bresume 1266
Job <1266> is being resumed

If the job is restored immediately, you can see through bjobs that the job is running as RUN.

% bjobs
1266  user1     RUN   normal    hosta       hostb       sleep 60    Jun 5 17:39:58

Job owners can only restore their own jobs, and lsfadministrator can restore any job.


When a job needs to be terminated, the bkill command can be used to signal the specified job. For example, if the job owner or LSF administrator executes the following command, job 1266 will be killed.

% bkill 1266
Job <1266> is being terminated

lsrun and lsgrun run interactive jobs

The lsrun command runs tasks on the current local or remote best available host, provided it finds the necessary resources and the appropriate host type. The lsgrun command is similar to the lsrun command, but it runs a task on a set of hosts.
An example of running the ls command is as follows: In this case, the command runs through LSF on the local host:

% lsrun ls -l /usr/share/lsf/cluster1/conf/
total 742
-rw-r--r--   1 root     lsf        11372 Jul 16 16:23 cshrc.lsf
-rw-r--r--   1 root     lsf          365 Oct 25 10:55 hosts
drwxr-xr-x   3 lsfadmin lsf          512 Jul 16 15:53 lsbatch
-rw-r--r--   1 lsfadmin lsf         1776 Nov 23 15:13 lsf.conf
-rw-r--r--   1 lsfadmin lsf         8453 Nov 16 17:46 lsf.shared
-rw-r--r--   1 lsfadmin lsf          578 Jul 16 15:53 lsf.task
-rw-r--r--   1 root     lsf        10485 Jul 16 17:08 profile.lsf

You can also specify the host on which to run the command. For example, run the hostname command on the remote host hosta:

% lsrun -v -m hosta hostname
<<Execute hostname on remote host hosta>>

Run the hostname command on three remote hosts:

% lsgrun -v -m "hosta hostb hostc" hostname
<<Executing hostname on hosta>>
<<Executing hostname on hostb>>
<<Executing hostname on hostc>>

Integrate applications with LSF

By integrating the application with LSF, you ensure that users can submit and run jobs without learning the LSF commands using the correct and complete job submission options.
Integrate applications with LSF in three ways:

  • Wrapping shell scripts
  • Binary executable for wrapper
  • Modify existing application source code and interfaces

Wrapping shell scripts

The easiest way to integrate is to put the bsub command into an executable file, just like a shell script. Wrapper scripts are executables used to launch applications through LSF. It provides users with a simple interface to run their jobs and is easy to deploy and maintain.
For example, if your application is named abc, rename ABC to abc_real, and create a wrapper script named abc:

#! /bin/sh
bsub -R "rusage[abc_license=1:duration=1]" abc_real

When users run abc, they are actually running a script that submits a job abc_to the LSF Real, which uses a job named abc_ Shared resources of the license.
For more information on using the resource requirement (rusage) string on the bsub command-R option to specify shared resources, see Managing software licenses and other shared resources.
You can enhance your integration by adding appropriate options to your scripts:

  • Queue jobs based on license availability
  • Copy input and output files from a local directory on the execution host
  • Calculate and estimate resource requirements

Binary program for wrappers

A wrapper binary is similar to a wrapper shell script in the form of a compiled binary executable. Compiled wrapper files usually run faster and more efficiently than shell scripts, and they also have access to LSF APIs (LSLIB and LSBLIB). Binary code is also safer because users cannot modify it without the source code and proper libraries, but developing wrapper binaries is more time consuming than wrapper shell scripts.

Modify existing application source code and interfaces

LSF has been tightly integrated with many common software products. IBM and other software application vendors provide tools and services for closer integration of LSF and other applications. By modifying the existing application user interface, you can enable simple job submission, license maximization, parallel execution, and other advanced LSF features. In some cases, you can run LSF jobs directly from the application user interface.

Added by jhenary on Thu, 03 Mar 2022 21:23:28 +0200