Use job scripts: -Zs.
You can build a job file one line at a time, or create it from another file, by running bsub without specifying a job to submit. When you do this, you start an interactive session in which bsub reads command lines from the standard input and submits them as a single batch job. You are prompted with bsub> for each line.
Use bsub -Zs to spool a job command file to the directory specified by the JOB_SPOOL_DIR parameter in lsb.params, and use the spooled file as the command file for the job.
Use the bmod -Zsn command to modify or remove the command file after the job has been submitted. Removing or modifying the original input file does not affect the submitted job.
For UNIX, the command lines are run as a Bourne shell (/bin/sh) script. Only valid Bourne shell command lines are acceptable in the following case:
% bsub -q simulation
bsub> cd /work/data/myhomedir bsub> myjob arg1 arg2 ......
bsub> rm myjob.log
bsub> ^D
Job <1234> submitted to queue <simulation>.
For Windows, the command lines are run as a batch file (.BAT). Only valid Windows batch file command lines are acceptable in the following case:
C:\> bsub -q simulation
bsub> cd \\server\data\myhomedir
bsub> myjob arg1 arg2 ......
bsub> del myjob.log
bsub> ^Z
Job <1234> submitted to queue <simulation>.
% bsub -q simulation < options_file
Job <1234> submitted to queue <simulation>.
On UNIX, options_file must be a text file that contains Bourne shell command lines. It cannot be a binary executable file.
On Windows, options_file must be a text file containing Windows batch file command lines.
Use bsub -Zs to spool a job command file to the directory specified by the JOB_SPOOL_DIR parameter in lsb.params, and use the spooled file as the command file for the job.
Use the bmod -Zsn command to modify or remove the command file after the job has been submitted. Removing or modifying the original input file does not affect the submitted job.
% bsub < myscript
Job <1234> submitted to queue <test>.
In this example, the myscript file contains job submission options as well as command lines to execute. When the bsub command reads a script from its standard input, it can be modified right after bsub returns for the next job submission.
% bsub myscript
Job <1234> submitted to default queue <normal>.
In this case, the command line myscript is spooled, instead of the contents of the myscript file. Later modifications to the myscript file can affect job behavior.
% bsub -q simulation bsub> #BSUB -q test
bsub> #BSUB -o outfile -R "mem>10"
bsub> myjob arg1 arg2
bsub> #BSUB -J simjob
bsub> ^D
Job <1234> submitted to queue <simulation>.
By default, LSF runs batch jobs using the Bourne (/bin/sh) shell. You can specify the shell under which a job is to run. This is done by specifying an interpreter in the first line of the script.
% bsub
bsub> #!/bin/csh -f
bsub> set coredump=‘ls |grep core‘
bsub> if ( "$coredump" != "") then
bsub> mv core core.‘date | cut -d" " -f1‘
bsub> endif
bsub> myjob
bsub> ^D
Job <1234> is submitted to default queue <normal>.
The bsub command must read the job script from standard input to set the execution shell. If you do not specify a shell in the script, the script is run using /bin/sh. If the first line of the script starts with a # not immediately followed by an exclamation mark (!), then /bin/csh is used to run the job.
% bsub
bsub> # This is a comment line. This tells the system to use /bin/csh to
bsub> # interpret the script.
bsub>
bsub> setenv DAY ‘date | cut -d" " -f1‘
bsub> myjob bsub> ^D
Job <1234> is submitted to default queue <normal>.
If running jobs under a particular shell is required frequently, you can specify an alternate shell using a command-level job starter and run your jobs interactively.