Qstat -f <JOBID> line breaks


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,


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 $_'

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

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


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).


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.
Obviously, all input/comments to improve the script is most welcome.

1 Like