Is it possible to access the walltime limit from within a SLURM script? For PBS Torque, this question has been answered here. Is there a similar environment value for SLURM?
-
what does the term "walltime" mean in these sort of compute management systems? – Charlie Parker Oct 10 '20 at 18:31
-
The walltime of a computer program is the time from the start and to the end/termination of the program. In context of a queueing system, this is the requested timeframe for the execution of a job. Eg. in slurm, if you request a timelimit of 1 hour (--time=1:00:00), then your wall time is 1 hour. – Thomas Espe Oct 11 '20 at 19:29
1 Answers
In SLURM, the walltime limit is set with --time:
#SBATCH --time=10:42:00
This value can be accessed through squeue, specifically via the %l format specifier:
$ squeue -h -j $SLURM_JOBID -o "%l"
10:42:00
$
There is also a %L format specifier that prints out the time left for the job to execute:
$ squeue -h -j $SLURM_JOBID -o "%L"
10:38:29
$
The -h option suppresses printing of the header in the output.
From man squeue:
%l Time limit of the job or job step in days-hours:minutes:seconds. The value may be "NOT_SET" if not yet established or "UNLIMITED" for no limit. (Valid for jobs and job steps)
%L Time left for the job to execute in days-hours:minutes:seconds. This value is calculated by subtracting the job's time used from its time limit. The value may be "NOT_SET" if not yet established or "UNLIMITED" for no limit. (Valid for jobs only)
%M Time used by the job or job step in days-hours:minutes:seconds. The days and hours are printed only as needed. For job steps this field shows the elapsed time since execution began and thus will be inaccurate for job steps which have been suspended. Clock skew between nodes in the cluster will cause the time to be inaccurate. If the time is obviously wrong (e.g. negative), it displays as "INVALID". (Valid for jobs and job steps)
Tested on slurm 17.02.2

- 306
- 1
- 6
-
But this time might be very different from the walltime limit set on job subscription via `-l walltime=HH:MM:SS`. – Julian Helfferich May 24 '17 at 04:23
-
Seems I misinterpreted your question, I'll update my answer shortly – Thomas Espe May 24 '17 at 04:57
-
Yes, this is exactly what I have been looking for. The `%L` format is particularly helpful. Thanks! – Julian Helfferich May 24 '17 at 06:38
-
For the sake of completeness, `scontrol show job $SLURM_JOBID` also includes information on the time limit. But I think your solution is much nicer. – Julian Helfferich May 24 '17 at 06:39
-
what does the term "walltime" mean in these sort of compute management systems? – Charlie Parker Oct 10 '20 at 18:31
-
@CharlieParker When running jobs on these kind of systems it's common to set a max time for the job to run. This allows slurm (or an alternative) to schedule jobs optimally across the available resources. However, if the job is still running when this maximum specified time is reach (the walltime) it will simply be killed - hence it can be useful for the job itself to know how long it has been given – Owen683 Apr 08 '22 at 10:23