[slurm-users] Make sacct show short job state codes?

Ole Holm Nielsen Ole.H.Nielsen at fysik.dtu.dk
Thu Mar 24 15:58:24 UTC 2022


Here is an example command for getting parseable output from sacct of all 
completed jobs during a specific period of time:

$ sacct -p -X -a -S 032322 -E 032422 -o JobID,User,State -s ca,cd,f,to,pr,oom

The fields are separated by | and can easily be parsed by awk.

Example output:

JobID|User|State|
4753873_126|catscr|TIMEOUT|
4753873_129|catscr|TIMEOUT|
4753873_136|catscr|FAILED|

I hope this helps.

/Ole

On 3/24/22 14:47, Brian Andrus wrote:
> I don't think that is part of sacct options. Feature request maybe.
> 
> Meanwhile, awk would be your friend here. Just post-process by piping the 
> output to awk and doing the substitutions before printing the output.
> 
> eg:
> 
>      sacct  |awk '{sub("CANCELLED","CA");sub("RUNNING","RU");print}'
> 
> Just add a 'sub' command for each substitution. It is tedious to setup but 
> will do the trick. You can also specify the specific field to do any 
> substitution on.
> 
> Brian Andrus
> 
> On 3/24/2022 6:12 AM, Chip Seraphine wrote:
>> I’m trying to shave a few columns off the output of some sacct output, 
>> and while it will happily accept the short codes (e.g. CA instead of 
>> CANCELLED) I can’t find a way to get it to report them.  Shaving down 
>> the columns using %N in –format just results in a truncated version of 
>> the long code, which is often not the same thing.
>>
>> Does anyone know if/how this can be done?



More information about the slurm-users mailing list