The following examples illustrate how customized esub and eexec executables can control job submission and execution.
#!/bin/sh. $LSB_SUB_PARM_FILE# Redirect stderr to stdout so echo can be used for error messages exec 1>&2# Check valid projectsif [ $LSB_SUB_PROJECT_NAME != "proj1" -o $LSB_SUB_PROJECT_NAME != "proj2" ]; thenecho "Incorrect project name specified"exit $LSB_SUB_ABORT_VALUEfiUSER=`whoami`if [ $LSB_SUB_PROJECT_NAME="proj1" ]; then# Only user1 and user2 can charge to proj1if [$USER != "user1" -a $USER != "user2" ]; thenecho "You are not allowed to charge to this project"exit $LSB_SUB_ABORT_VALUEfifi
#!/bin/sh. $LSB_SUB_PARM_FILE# Redirect stderr to stdout so echo can be used for error messages exec 1>&2USER=`whoami`# Make sure userA is using the right queue queueAif [ $USER="userA" -a $LSB_SUB_QUEUE != "queueA" ]; thenecho "userA has submitted a job to an incorrect queue"echo "...submitting to queueA"echo 'LSB_SUB_QUEUE="queueA"' > $LSB_SUB_MODIFY_FILEfi# Make sure userB is using the right shell (/bin/sh)if [ $USER="userB" -a $SHELL != "/bin/sh" ]; thenecho "userB has submitted a job using $SHELL"echo "...using /bin/sh instead"echo 'SHELL="/bin/sh"' > $LSB_SUB_MODIFY_ENVFILEfi# Deny userC the ability to submit a jobif [ $USER="userC" ]; thenecho "You are not permitted to submit a job."exit $LSB_SUB_ABORT_VALUEfi
#!/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" != "" ] ; thenexit 0fiTASKDIR="/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 itif [ "test -d $TASKDIR" != "0" ] ; thenmkdir $TASKDIR > /dev/null 2>&1fi# Need to make sure LS_JOBPID, and USER are defined# exit normallyif [ "test -z $LS_JOBPID"="0" ] ; thenexit 0elif [ "test -z $USER" = "0" ] ; thenexit 0fitaskFile="$TASKDIR/$LS_JOBPID.$USER"# Fork grandchild to stay around for the duration of the tasktouch $taskFile >/dev/null 2>&1((while : ;dokill -0 $LS_JOBPID >/dev/null 2>&1if [ $? -eq 0 ] ; thensleep 10 # this is the poll interval# increase it if you want but# see the elim for its# corresponding update intervalelserm $taskFile >/dev/null 2>&1exit 0fidone)&)&wait
A combination of esub and eexec executables can be used to pass AFS/DCE tokens from the submission host to the execution host. LSF passes data from the standard output of esub to the standard input of eexec. A daemon wrapper script can be used to renew the tokens.