When I use the --state option (or -s) wit sacct I always get an empty list returned. For example
sacct --state=completed --format=User,JobID,Jobname%50,partition,state,time
or
sacct --state=canceled --format=User,JobID,Jobname%50,partition,state,time
both return empty list. The only exception is for pending tasks in which case I do get an non-empty list. sacct
itself or used with the option --starttime does show tasks in all states. They just don't show up when using the --state filter even when I copy the status there.
What am I doing wrong? How do I get a list of all tasks in a certain state?
You have to specify the --starttime
and --endtime
to see the jobs completed in a specific time duration. Otherwise the start and end time will be the current time when the --state option is specified and only currently running jobs can be displayed (Check here).
For example,
sacct --starttime $(date -d 'last week' +%D-%R) --endtime midnight --state COMPLETED
The documentation states the following:
A start and/or end time must be specified to view information about jobs not currently running. See the JOB STATE CODES section below for a list of state designators. Multiple state names may be specified using comma separators. Either the short or long form of the state name may be used (e.g. CA or CANCELLED) and the name is case insensitive (i.e. ca and CA both work).
These are the job state codes:
CA CANCELLED Job was cancelled by the user or a sysadmin
CD COMPLETED Job finished normally, with exit code 0
F FAILED Job finished abnormally, with a non-zero exit code
OOM OUT_OF_MEMORY Job was killed for using too much memory
PD PENDING Job is waiting to start
R RUNNING Job is currently running
TO TIMEOUT Job was killed for exceeding its time limit
Another example: to see jobs that completed, either normally or abnormally, since July 12th, without job steps:
sacct -S 0712 -s CD,F
Visit here for more information.