Bhargav Katkam Bhargav Katkam - 6 months ago 13
Bash Question

Ensuring a shell script to be executed as lsf job only

I have shell script and want to disable it's execution as normal job. It should be executed only as bjob in LSF

How can I make sure this with in script

Answer
if [ -z "$LSF_JOB_TIMESTAMP_VALUE" ]; then
  echo "local jobs disabled. Please run through LSF only --"
  exit
fi
currentTime=$(date +%s)
diffTime=$(expr $currentTime - $LSF_JOB_TIMESTAMP_VALUE)
if [ $diffTime -gt 1 ]; then
  echo "local jobs disabled. Please run through LSF only --"
  exit
fi

I have added these lines in script, It is able to abort when not on lsf. As time stamps are being checked, users cannot bypass it