'Slurm environment variable for requested time

For a slurm job, the environment variable $SLURM_JOB_NUM_NODES gives the number of nodes requested.

Is there a similar variable that gives the run time requested? I couldn't find the answer and I have tried $SLURM_JOB_TIME, $SLURM_TIME and $SLURM_SUBMIT_TIME, but none of these works.

Ultimate goal is to let the script I run know how much time is given to run, see an example below:

#!/bin/bash
#SBATCH --account=abc
#SBATCH --time=1:00:00
#SBATCH --job-name=xyz
#SBATCH --nodes=2
#SBATCH --tasks-per-node=1

python my_python_script.py --run_time $SLURM_JOB_TIME --run_nodes $SLURM_JOB_NUM_NODES


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source