LSF Version 7.3 - Administering Platform LSF

Configuring Pre- and Post-Execution Commands
562 Administering Platform LSF
Configuring Pre- and Post-Execution Commands
Pre-execution commands can be configured at the job level, in queues, or in
application profiles.
Post-execution commands can be configured at the job level, in queues or in
application profiles.
Job-level commands
Job-level pre-execution and post-execution commands require no configuration.
Use the
bsub -E option to specify an arbitrary command to run before the job
starts. Use the
bsub -Ep option to specify an arbitrary command to run after the
job finishes running.
Example The following example shows a batch job that requires a tape drive. The user
program
tapeCheck exits with status zero if the specified tape drive is ready:
bsub -E "/usr/share/bin/tapeCheck /dev/rmt01" myJob
Queue-level commands
Use the PRE_EXEC and POST_EXEC keywords in the queue definition
(
lsb.queues) to specify pre- and post-execution commands.
The following points should be considered when setting up pre- and post-execution
commands at the queue level:
If the pre-execution command exits with a non-zero exit code, then it is
considered to have failed and the job is requeued to the head of the queue. This
feature can be used to implement customized scheduling by having the
pre-execution command fail if conditions for dispatching the job are not met.
Other environment variables set for the job are also set for the pre- and
post-execution commands.
When a job is dispatched from a queue which has a post-execution command,
LSF remembers the post-execution command defined for the queue from
which the job is dispatched. If the job is later switched to another queue or the
post-execution command of the queue is changed, LSF still runs the original
post-execution command for this job.
When the post-execution command is run, the environment variable,
LSB_JOBEXIT_STAT, is set to the exit status of the job. See the man page for
the
wait(2) command for the format of this exit status.
The post-execution command is also run if a job is requeued because the jobs
execution environment fails to be set up, or if the job exits with one of the
queues REQUEUE_EXIT_VALUES. The LSB_JOBPEND environment
variable is set if the job is requeued. If the jobs execution environment could
not be set up, LSB_JOBEXIT_STAT is set to 0.
Running of post-execution commands upon restart of a rerunnable job may
not always be desirable; for example, if the post-exec removes certain files, or
does other cleanup that should only happen if the job finishes successfully. Use
LSB_DISABLE_RERUN_POST_EXEC=Y in
lsf.conf to prevent the
post-exec from running when a job is rerun.