Skip to main content

bsub

Overview

bsub is used to submit jobs to the FSCHED cluster and is compatible with the LSF command-line interface. It supports both batch and interactive job submission and provides rich resource management and scheduling options.


Options

I/O and Working Directory

OptionRequires ValueFormatDescription
-cwdYesPath stringSpecify the job working directory. Supports relative and absolute paths.
-iYesFile pathRead job standard input from the specified file.
-oYesFile path (supports %J, %I placeholders)Append standard output to the specified file.
-ooYesFile path (supports %J, %I placeholders)Overwrite standard output to the specified file.
-eYesFile path (supports %J, %I placeholders)Append standard error to the specified file.
-eoYesFile path (supports %J, %I placeholders)Overwrite standard error to the specified file.
Placeholder Notes
  • %J - Job ID (automatically converted to %A in FSCHED)
  • %I - Array index (automatically converted to %a in FSCHED)

Resource Allocation

OptionRequires ValueFormatDescription
-nYesmin_tasks[,max_tasks]Specify the number of tasks for the job. You can provide a minimum or a min/max range.
-mYesHostname list (space-separated)Specify the host nodes on which the job runs.
-RYesResource requirement expressionSpecify resource requirements; supports span, rusage[mem=...], rusage[tmp=...].
-xNoNoneExclusive mode; the job exclusively uses the allocated nodes.
-gpuYesnumber[/mode][/j_exclusive][/mps]Specify GPU resource requirements.
Resource Expression Notes

The -R option supports the following formats:

  • span[hosts=N] - Allocate across N hosts
  • span[ptile=N] - Allocate N tasks per host
  • rusage[mem=SIZE] - Memory requirement (for example rusage[mem=4G])
  • rusage[tmp=SIZE] - Temporary space requirement (for example rusage[tmp=10G])

Process Resource Limits (ulimit)

OptionRequires ValueFormatDescription
-MYesMemory size (MB)Set per-process memory limit (ulimit -m).
-CYesSize or unlimitedSet core file size limit (ulimit -c).
-cYesTime (milliseconds)Set CPU time limit (ulimit -t).
-DYesSize or unlimitedSet data segment size limit (ulimit -d).
-FYesSize or unlimitedSet file size limit (ulimit -f).
-SYesSize or unlimitedSet stack size limit (ulimit -s).
-vYesSize or unlimitedSet virtual memory limit (ulimit -v).
-pYesCount or unlimitedSet process count limit (ulimit -u).
-TYesCountSet thread count limit.
-ulNoNoneInherit resource limits from the current shell.

Time and Scheduling

OptionRequires ValueFormatDescription
-WYes[hour:]minuteSet job run time limit. For example 2:30 means 2 hours 30 minutes.
-bYesDate-time stringSet the earliest start time for the job.
-tYesDate-time stringSet the termination deadline for the job.
-wYesDependency expressionSet job dependencies. Supports done(), ended(), exit(), started().
-HNoNonePut the job into suspended state after submission.
-tiNoNoneEnable automatic orphan job termination.
Dependency Expression Examples
  • done(12345) - Wait for job 12345 to finish successfully
  • ended(12345) - Wait for job 12345 to finish (success or failure)
  • exit(12345,0) - Wait for job 12345 to exit with code 0
  • started(12345) - Wait for job 12345 to start running

Job Attributes

OptionRequires ValueFormatDescription
-JYesjobname[index_list]Specify the job name. Supports arrays like myjob[1-10].
-JdYesDescription textSpecify job description.
-qYesQueue nameSpecify the submission queue.
-PYesProject nameSpecify the project the job belongs to.
-GYesUser group nameSpecify the fair-share group.
-spYesPriority (0-100)Set the user-specified job priority; higher value means higher priority.
-rNoNoneEnable automatic retry on job failure.
-rnNoNoneDisable automatic retry on job failure.

Interactive Jobs

OptionRequires ValueFormatDescription
-INoNoneSubmit an interactive job with direct input/output forwarding.
-IsNoNoneSubmit an interactive job with a pseudo-terminal and shell.
-IpNoNoneSubmit an interactive job with a pseudo-terminal, supports terminal control sequences.
-IXNoNoneSubmit an interactive job with X11 GUI.
-LYesShell path (absolute path)Specify the login shell.
-ttyNoNoneDisplay job output and error messages on the screen.
Mutually Exclusive Options

-I, -Is, -Ip, and -IX are mutually exclusive; only one can be used.

Execution Commands

OptionRequires ValueFormatDescription
-EYesCommand stringPre-execution command run before the job starts.
-EpYesCommand stringPost-execution command run after the job ends.

Environment Variable Control

OptionRequires ValueFormatDescription
-envYesEnvironment variable specControl environment variable propagation. Supports all, none, selective propagation, etc.
Environment Variable Spec Format
  • all - Propagate all environment variables (default)
  • none - Do not propagate any environment variables
  • VAR1,VAR2 - Propagate only specified variables
  • ~VAR1,~VAR2 - Exclude specified variables
  • VAR=value - Set variable values
  • Combinations are allowed, for example all,~TMPDIR,MYVAR=newvalue

Notifications

OptionRequires ValueFormatDescription
-BNoNoneSend an email notification when the job starts.
-NNoNoneSend an email notification when the job ends.
-NeNoNoneSend an email notification when the job exits.
-uYesEmail addressSpecify the email recipient address (not fully implemented yet).

Other

OptionRequires ValueFormatDescription
-KNoNoneWait for the job to complete and return the exit code. Batch jobs only.
-VNoNonePrint version information and exit.
Option Limitations

The -K option applies only to batch jobs and is mutually exclusive with interactive options (-I, -Is, -Ip, -IX).


Examples

Basic Submission

# Submit a simple batch job
bsub ./myjob.sh

# Submit a job with a name
bsub -J myjob ./run.sh

# Submit an array job
bsub -J "arrayjob[1-10]" ./process.sh

Resource Allocation

# Specify task count and run time
bsub -n 8 -W 2:30 ./parallel_job.sh

# Specify memory and temporary space requirements
bsub -R "rusage[mem=4G,tmp=10G]" ./data_process.sh

# Allocate across multiple nodes
bsub -n 16 -R "span[hosts=4]" ./mpi_job.sh

# Specify GPU resources
bsub -gpu 2 ./gpu_task.sh

Process Limits

# Set memory and CPU time limits
bsub -M 2048 -c 3600000 ./limited_job.sh

# Set multiple resource limits
bsub -M 4096 -S 102400 -F 1048576 ./constrained_job.sh

# Inherit current shell resource limits
bsub -ul ./inherit_limits.sh

I/O Redirection

# Redirect output to files
bsub -o output.%J.log -e error.%J.log ./task.sh

# Overwrite output files
bsub -oo output.log -eo error.log ./task.sh

# Use array task placeholders
bsub -J "job[1-5]" -o "out.%J.%I.log" ./array_task.sh

Scheduling Control

# Delay job start
bsub -b "2025-01-01:09:00" ./morning_job.sh

# Set dependencies
bsub -w "done(12345)" ./dependent_job.sh

# Suspend job after submission
bsub -H ./paused_job.sh

# Set priority
bsub -sp 80 ./high_priority.sh

Interactive Jobs

# Basic interactive job
bsub -I bash

# Interactive job with pseudo-terminal
bsub -Ip -n 4 python

# X11 GUI job
bsub -IX matlab

# Use a login shell
bsub -Is -L /bin/bash

Environment Variable Control

# Do not propagate any environment variables
bsub -env "none" ./clean_env.sh

# Propagate only specified variables
bsub -env "PATH,HOME,USER" ./selective.sh

# Exclude specific variables
bsub -env "all,~TMPDIR,~DISPLAY" ./filtered.sh

# Set variable values
bsub -env "DEBUG=1,WORKERS=8" ./configured.sh

Notifications and Waiting

# Send emails on start and end
bsub -B -N ./notify_job.sh

# Wait for job completion
bsub -K ./wait_job.sh
echo "Job completed, exit code: $?"

Combined Usage

# Full job configuration example
bsub \
-J "production[1-100]" \
-q normal \
-n 8 \
-W 4:00 \
-R "span[hosts=1] rusage[mem=8G]" \
-M 8192 \
-o "logs/output.%J.%I.log" \
-e "logs/error.%J.%I.log" \
-P myproject \
-sp 50 \
-B -N \
./production_task.sh

Notes

Limitations

  1. Resource expression support

    • The -R option supports only span[hosts=N], span[ptile=N], rusage[mem=SIZE], and rusage[tmp=SIZE].
    • Advanced LSF resource syntax such as select, cu, and affinity is not supported.
  2. Email notifications

    • The -u option is not fully implemented yet; email notifications may be limited by system configuration.
  3. GPU resources

    • The -gpu option supports parameter parsing; full functionality depends on FSCHED GPU scheduling configuration.
  4. Priority

    • The -sp option accepts priorities 0-100; actual scheduling behavior depends on system configuration.

Placeholder Conversion

  • LSF %J (job ID) is automatically converted to FSCHED %A.
  • LSF %I (array index) is automatically converted to FSCHED %a.
  • Placeholders are valid only for -o, -oo, -e, and -eo.

Option Conflicts

  • Interactive options (-I, -Is, -Ip, -IX) are mutually exclusive.
  • -K cannot be used together with interactive options.
  • -o conflicts with -oo, and -e conflicts with -eo (the latter overwrites the former).

Default Behavior

  • If -o or -e is not specified, standard output and error are discarded by default (sent to /dev/null).
  • If -cwd is not specified, the current working directory at submission time is used.
  • Automatic job retry is enabled by default (-r), and can be disabled with -rn.

Unsupported Options

The following LSF options are not supported in the current version. Using them will show a warning but will not affect job submission:

  • CSM-related options (for example -alloc_flags, -cn_cu)
  • Advanced LSF features (for example -app, -sla, -clusters)
  • File staging (for example -f, -stage)
  • Checkpointing and migration (for example -k, -mig)
  • Alternative submission formats (for example -json, -yaml)

For the complete list of unsupported options, see the FSCHED technical documentation.