Useful Job Environment Variables

Some of the environment variables set by the scheduler and available to a job at runtime:

Example

To see all environment variable available to a job, submit a job that calls env:

$ cd ~/test/
$ echo "env" | qsub -cwd -j yes -pe smp 4 -l h_rt=00:01:00 -N test_envvar
Your job 135988 ("test_envvar") has been submitted

When finished, check the content of the job output file:

$ grep -E "(HOSTNAME|NSLOTS|NHOSTS|_ID|_NAME|PWD)" test_envvar.o135988
HOSTNAME=qb3-id1
NHOSTS=1
SGE_TASK_ID=undefined
PWD=/wynton/home/alice/test
JOB_NAME=test_envvar
JOB_ID=135988
SGE_CLUSTER_NAME=hpccoreclus
NSLOTS=4

$ cat test_envvar.o135988
MANPATH=/opt/sge/man:/usr/share/man/overrides:/usr/share/man:/usr/local/share/man
HOSTNAME=qb3-id1
SGE_TASK_STEPSIZE=undefined
SHELL=/bin/sh
TERM=
HISTSIZE=1000
NHOSTS=1
SGE_O_WORKDIR=/wynton/home/alice/test
TMPDIR=/scratch/135988.1.member.q
SGE_O_HOME=/wynton/home/alice
SGE_ARCH=lx-amd64
SGE_CELL=hpccore
RESTARTED=0
QT_GRAPHICSSYSTEM_CHECKED=1
ARC=lx-amd64
USER=alice
SGE_TASK_LAST=undefined
QUEUE=member.q
SGE_TASK_ID=undefined
MAIL=/var/spool/mail/alice
SGE_BINARY_PATH=/opt/sge/bin/lx-amd64
PATH=/opt/sge/bin:/opt/sge/bin/lx-amd64:/scratch/135988.1.member.q:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin
SGE_STDERR_PATH=/wynton/home/alice/test/test_envvar.o135988
PWD=/wynton/home/alice/test
SGE_STDOUT_PATH=/wynton/home/alice/test/test_envvar.o135988
SGE_ACCOUNT=sge
SGE_RSH_COMMAND=builtin
LANG=en_US.UTF-8
MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles
JOB_SCRIPT=/var/spool/sge/hpccore/qb3-id1/job_scripts/135988
JOB_NAME=test_envvar
LOADEDMODULES=
SGE_ROOT=/opt/sge
REQNAME=test_envvar
HISTCONTROL=ignoredups
SGE_JOB_SPOOL_DIR=/var/spool/sge/hpccore/qb3-id1/active_jobs/135988.1
ENVIRONMENT=BATCH
PE_HOSTFILE=/var/spool/sge/hpccore/qb3-id1/active_jobs/135988.1/pe_hostfile
HOME=/wynton/home/alice
SHLVL=2
SGE_CWD_PATH=/wynton/home/alice/test
NQUEUES=1
SGE_O_LOGNAME=alice
SGE_O_MAIL=/var/spool/mail/alice
TMP=/scratch/135988.1.member.q
JOB_ID=135988
LOGNAME=alice
PE=smp
MODULESHOME=/usr/share/Modules
SGE_TASK_FIRST=undefined
LESSOPEN=||/usr/bin/lesspipe.sh %s
SGE_O_PATH=/usr/lib64/openmpi/bin:/opt/sge/bin:/opt/sge/bin/lx-amd64:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
SGE_CLUSTER_NAME=hpccoreclus
SGE_O_HOST=qb3-login1
SGE_O_SHELL=/bin/bash
REQUEST=test_envvar
NSLOTS=4
SGE_STDIN_PATH=/dev/null
_=/bin/env