LSF Version 7.3 - Platform LSF Configuration Reference
Changing job submission parameters using esub
The following example shows an esub that modifies job submission options and environment
variables based on the user name that submits a job. This esub writes the changes to
LSB_SUB_MODIFY_FILE for userA and to LSB_SUB_MODIFY_ENVFILE for userB. LSF
rejects all jobs submitted by userC without writing to either file:
#!/bin/sh
. $LSB_SUB_PARM_FILE
# Redirect stderr to stdout so echo can be used for error messages exec 1>&2
USER=`whoami`
# Make sure userA is using the right queue queueA
if [ $USER="userA" -a $LSB_SUB_QUEUE != "queueA" ]; then
echo "userA has submitted a job to an incorrect queue"
echo "...submitting to queueA"
echo 'LSB_SUB_QUEUE="queueA"' > $LSB_SUB_MODIFY_FILE
fi
# Make sure userB is using the right shell (/bin/sh)
if [ $USER="userB" -a $SHELL != "/bin/sh" ]; then
echo "userB has submitted a job using $SHELL"
echo "...using /bin/sh instead"
echo 'SHELL="/bin/sh"' > $LSB_SUB_MODIFY_ENVFILE
fi
# Deny userC the ability to submit a job
if [ $USER="userC" ]; then
echo "You are not permitted to submit a job."
exit $LSB_SUB_ABORT_VALUE
fi
Monitoring the execution environment using eexec
This example shows how you can use an eexec to monitor job execution:
#!/bin/sh
# eexec
# Example script to monitor the number of jobs executing through RES.
# This script works in cooperation with an elim that counts the
# number of files in the TASKDIR directory. Each RES process on a host
# will have a file in the TASKDIR directory.
# Don’t want to monitor lsbatch jobs.
if [ "$LSB_JOBID" != "" ] ; then
exit 0
fi
TASKDIR="/tmp/RES_dir"
# directory containing all the task files
#for the host.
# you can change this to whatever
# directory you wish, just make sure anyone
# has read/write permissions.
# if TASKDIR does not exist create it
if [ "test -d $TASKDIR" != "0" ] ; then
mkdir $TASKDIR > /dev/null 2>&1
fi
# Need to make sure LS_JOBPID, and USER are defined
# exit normally
if [ "test -z $LS_JOBPID"="0" ] ; then
exit 0
elif [ "test -z $USER" = "0" ] ; then
exit 0
fi
taskFile="$TASKDIR/$LS_JOBPID.$USER"
# Fork grandchild to stay around for the duration of the task
touch $taskFile >/dev/null 2>&1
(
(while : ;
do
kill -0 $LS_JOBPID >/dev/null 2>&1
if [ $? -eq 0 ] ; then
sleep 10 # this is the poll interval
# increase it if you want but
# see the elim for its
Feature: External job submission and execution controls
Platform LSF Configuration Reference 79