Qstat -f <JOBID> line breaks


#1

Hi,

For various reasons, I need to parse information about jobs - such as getting the job comment (if any).
In such circumstances, it would be convenient to get each job attribute on a single line - even if the line could be very long.
The present full-format output breaks “long info” over several lines, adding extra spaces to subsequent lines, such as in:

    Submit_arguments = -l walltime=00:02:00 -l select=2:ncpus=2 -l place=scatte
        r:excl -- /bin/sleep 30

Is there a simple way (say a qstat flag), where I can get each attribute on a single line? Alternatively, just get a single named attribute? (I could write a script to do the reformatting, but I consider that a hack).

Many thanks,

/Bjarne


PP-483: As a user or admin, I would like qstat to return a full job attribute list with 1 line per job attribute, so that I can more easily use tools like grep to find the information I am looking for regarding my jobs
PP-483: As a user or admin, I would like qstat to return a full job attribute list with 1 line per job attribute, so that I can more easily use tools like grep to find the information I am looking for regarding my jobs
#2

Here is a hack to do it. It relies on the assumption that continued lines in qstat start with a single tab char ("\t") before the content. And that there are no blanks at end-of-line. Thus, we can simply delete all “newline-tab” combos from the qstat -f output.

This is not pretty (well, it’s pretty ugly), but it seems to work.

qstat -f | perl -e '$/=undef;$_=<>;s/\n\t//g;print $_'

[EDIT:]
If you prefer sed over perl, then you can do stuff like:

qstat -f | sed ':a;N;$!ba;s/\n\t//g'

Anyway, to get just the Submit_arguments (the full attribute, and only this attribute) of a single job, you may do stuff like

attrnam=Submit_arguments
qstat -f <JOBID> | perl -e '$/=undef;$_=<>;s/\n\t//g;print $_'\
   |grep "^\s\+$attrnam = "|sed -e "s/^\s\+$attrnam = //"

For my job, this outputs, on a single line:

-l walltime=00:02:00 -l select=2:ncpus=2 -l place=scatter:excl -- /bin/sleep 30

YMMV.

If somebody knows a “nicer way” - or even a secret/magic trick to get “wide lines” and “full output” with qstat, let me know (-w and -f don’t mix).

/Bjarne

PS [EDIT]: Just in case somebody is interested, I created a script to interface to qstat. It takes care of the “\n\t”-issue, and also can give you just the value of a single named attribute for a named job.
https://sourceforge.net/p/dcoo/cluster-tools/ci/master/tree/pbs/qstat2lin
Obviously, all input/comments to improve the script is most welcome.


Runjob hook modify select problem