Julian Helfferich
Julian Helfferich

Reputation: 1320

SLURM: Access walltime limit from script

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?

Upvotes: 4

Views: 6839

Answers (1)

Thomas Espe
Thomas Espe

Reputation: 326

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

Upvotes: 7

Related Questions