You may want to throw in a uniq command in case the user runs multiple jobs on some nodes:

# squeue -u user123 -h -o "%N" | tr '\n' , | xargs scontrol show hostlistsorted
b[135,135,135]

This gives a better list:

# squeue -u user123 -h -o "%N" | uniq | tr '\n' , | xargs scontrol show hostlistsorted
b135

BTW, if you enter a non-existent user, the output is an unexpected error message and a long help info :-)

/Ole

On 06/22/2017 11:29 AM, Jens Dreger wrote:

I think

   squeue -u user123 -h -o "%N" | tr '\n' , | xargs scontrol show hostlistsorted

should also do it... Slightly better to remember ;)

On Thu, Jun 22, 2017 at 02:59:11AM -0600, Loris Bennett wrote:

Hi,

I can generate a list of node lists on which the jobs of a given user
are running with the following:

   $ squeue -u user123 -h -o "%N"
   node[006-007,014,016,021,024]
   node[012,094]
   node[005,008-011,013,015,026,095,097-099]

I would like to merge these node lists to obtain

   node[005-016,021,024,026,094-095,097-099]

I can do the following:

   $ squeue -u user123 -h -o "%N" | xargs -I {} scontrol show hostname {} | sed 
':a;N;$!ba;s/\n/,/g' | xargs scontrol show hostlistsorted
   node[005-016,021,024,026,094-095,097-099]

Would it be worth adding an option to allow the delimiter in the output
of 'scontrol show hostname' to be changed from an newline to, say, a
comma?  That would permit easier manipulation of node lists without
one having to google the appropiate sed magic.



--
Ole Holm Nielsen
PhD, Manager of IT services
Department of Physics, Technical University of Denmark,
Building 307, DK-2800 Kongens Lyngby, Denmark
E-mail: [email protected]
Homepage: http://dcwww.fysik.dtu.dk/~ohnielse/
Tel: (+45) 4525 3187 / Mobile (+45) 5180 1620

Reply via email to