If I run a Slurm job with
sbatch
, [I can specify output and error filenames](https://unix.stackexchange.com/questions/285690/slurm-custom-standard-output-name?rq=1) with a [custom format](https://slurm.schedmd.com/sbatch.html#lbAH) . But how can I **look up** these filenames, given the job ID (e.g. 123456
) of a running job?
For example:
sbatch --wrap="bash -c 'echo stderr here >&2; echo stdout here; sleep 60'" \
--error="slurm_outputs/stderr_%j_%N_%x.out" \
--output="slurm_outputs/stdout_%j_%N_%x.out"
This uses the placeholders
- %j
for the job ID (123456
),
- %N
for the name of the node it's running on (node1
),
- %x
for the job name (wrap
),
so we end up with files stderr_123456_node1_wrap.out
and stdout_123456_node1_wrap.out
under slurm_outputs
.
**Near-solution:** I can get a json from squeue
, which *almost* gives me what I want:
$ squeue --jobs=123456 --json |
jq '.jobs[].standard_output, .jobs[].standard_error'
"/path/to/slurm_outputs/stdout_123456_%N_wrap.out"
"/path/to/slurm_outputs/stderr_123456_%N_wrap.out"
But the %N
string is left uninterpreted—which I imagine is because the job scheduler doesn't know what node it's going to use before it allocates one, and squeue
just has this old information.
So I can’t immediately do something like
tail -f "$(squeue --jobs=123456 --json |
jq --raw-output '.jobs[].standard_output')"
to follow the standard output of the job I just submitted. But that would be nice!
Does slurm provide a way to look up the “finished” filename (i.e., with all placeholders filled)?
Asked by wobtax
(1135 rep)
May 9, 2025, 06:13 PM
Last activity: Jun 4, 2025, 04:16 PM
Last activity: Jun 4, 2025, 04:16 PM