LinuxCommandLibrary

bsub

Submit jobs to a batch system

TLDR

Submit a script file as a job

$ bsub [path/to/script.sh]
copy

Submit a job to a specific queue
$ bsub -q [queue_name] make all
copy

Submit a job with a name and redirect output and error
$ bsub -J [job_name] --output [path/to/output.log] --error [path/to/error.log] [path/to/script.sh]
copy

Request 8 CPU cores and 16GB memory for a command
$ bsub -n 8 -M 16G cargo build --release
copy

Run an interactive shell in the current session
$ bsub -I bash
copy

Submit a job with a runtime limit of 45 minutes
$ bsub -W 45 [path/to/script.sh]
copy

SYNOPSIS

bsub [options] [command]

PARAMETERS

-q
    Submit job to specified queue

-J
    Assign name to job or job array

-n
    Number of task slots (hosts/processors)

-R ""
    Resource requirements (e.g., "rusage[mem=1024]")

-o
    Standard output file

-e
    Standard error file

-cwd


    Change to working directory before execution

-P
    Charge job to specified project

-G
    Run job under user group

-u
    Run job as specified user

-W
    CPU time limit (minutes)

-M
    Maximum resident memory (MB)

-R "span[hosts=1]"
    Parallel job span across hosts

-app
    Use application-specific profile

-env
    Environment variable handling (none, all, copy)

-L
    Library file path

-a
    Execution action (e.g., "run.local")

-Is
    Interactive job (allocates pseudo-tty)

-K
    Wait for job completion (synchronous)

-m
    Run job on specified host(s)

-N
    Do not send email notifications

-T
    License tokens required

-v
    Temporary scratch directory

-B
    Pre-execution and post-execution commands

-Ep ""
    Job pre-execution command

-Eo ""
    Job post-execution command

DESCRIPTION

The bsub command is a key utility in IBM Spectrum LSF (Load Sharing Facility), a workload management platform for distributed HPC environments.

It submits interactive, batch, or parallel jobs to specified queues on a cluster, allowing users to specify resource requirements, dependencies, and execution parameters.

bsub handles job submission by communicating with the LSF mbatchd daemon on the submission host, which queues the job for execution on available hosts based on policies like fairshare scheduling and resource limits.

Jobs can be simple scripts or complex MPI applications, with output redirected to files. It supports advanced features like job arrays, resource reservations, and licensing constraints.

Essential for cluster users to avoid direct host logins, ensuring efficient resource utilization and load balancing across nodes.

CAVEATS

Requires LSF environment variables (LSF_ENVDIR, LSB_SHAREDIR); not available on standard Linux without LSF installation.
Not for interactive use without -Is or -I; job IDs returned on stdout unless redirected.
Options case-sensitive; resource strings must be quoted properly to avoid shell expansion.

JOB ARRAYS

Use -J "name[%index_range%step]" for parametric jobs, e.g., -J "sim[1-100%10]".

EXIT STATUS

Returns job ID on success (e.g., 12345); 1-255 for errors like invalid options or queue full.

ENVIRONMENT

Relies on $LSF_BINDIR, $LSF_LIBDIR; use 'bsub -help' or 'bsub -V' for version/options list.

HISTORY

Developed by Platform Computing in 1990s as Load Sharing Facility (LSF); evolved into IBM Spectrum LSF (v10+). Widely used in HPC since early 2000s for job scheduling.

SEE ALSO

bjobs(1), bkill(1), bqueues(1), bacct(1), bruntime(1), bsub -help(1)

Copied to clipboard