With SLURM, I run the command
squeue -u enter_username
and I get an table output with the following heading
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
I'm trying to capture the duration of time the job has been running for. I couldn't find an environmental variable provided by SLURM to capture this time, so I think I'm left parsing the output of squeue
. This is not as easy as I thought it would be, because the wall clock does not have a fixed format. In other words, it doesn't always show dd-HH:MM:SS. If there are no days, then the output is just HH:MM:SS, and if there are no hours the output is MM:SS, etc.
I'm doing this with bash and I need to capture the day (dd) and hour (HH) and assign each of them to a variable. I'm having a hard time doing this when the format is dynamic.
To capture the time entry, I'm simply doing the following (within a SLURM bash script)
time_str=$(squeue -u enter_username | grep "$SLURM_JOB_ID" | cut -d "R" -f2- | gawk '{print $1}')
As I said before, time_str
does not have a fixed format. Hoping someone with experience can help.