Platform LSF Administration Guide Version 6.2
Configuring Pre- and Post-Execution Commands
Administering Platform LSF
482
Configuring Pre- and Post-Execution Commands
Pre- and post-execution commands can be configured at the job level or on a per-queue
basis.
Job-level commands
Job-level pre-execution commands require no configuration. Use the bsub -E option
to specify an arbitrary command to run before the job starts.
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 pre-execution command, LSF
will remember 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 will still run 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 job’s
execution environment fails to be set up, or if the job exits with one of the queue’s
REQUEUE_EXIT_VALUES.
The LSB_JOBPEND environment variable is set if the job is requeued. If the job’s
execution environment could not be set up, LSB_JOBEXIT_STAT is set to 0.
See “Automatic Job Requeue” on page 387 for more information about job requeue.
◆
Running of post-execution commands upon restart of a rerunanble 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.
See “Automatic Job Rerun” on page 391 for more information about rerunnable
jobs.