Body
SLURM Environment Variables
SLURM sets several environment variables when it starts a job. These variables are in the job environment and are preceded with a "$". They are useful for your SLURM scripts to automatically adapt to the resources requested for the job.
Common Environment Variables
Some commonly used SLURM environment variables are listed in the table below. The full list can be found in the SLURM documentation.
| Variable |
Value |
| $SLURM_NTASKS |
The number of SLURM tasks |
| $SLURM_JOB_ID |
The Job ID of the running job |
| $SLURM_ARRAY_TASK_ID |
The array index |
| $SLURM_NNODES |
The number of nodes a job is split across. Only unknown if directive --nodes was not set. |