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
The environment variables that are set in Slurm jobs are called output environment variables ; they are listed in the sbatch manpage.
No such variable exists for the time requested.
Within the submission script, you can query the Slurm controller for the information with squeue
. Your script could look like
TIME=$(squeue -j $SLURM_JOB_ID -h --Format TimeLimit)
python my_python_script.py --run_time $TIME --run_nodes $SLURM_JOB_NUM_NODES