Reuti <[email protected]> wrote: >> how do I find out the host a particular job is currently >> running on?
>> "qstat -j 1897" (for example) only lists the requested >> queue. "qhost -u tools.wikilint" works, but is very un- >> friendly to parse in a shell script. >> Do I have to pipe "qhost -u tools.wikilint -xml" to an XML >> parser, or is there a more convenient way to get the host? > Another approach could be to use a prolog to add the assignment of nodes to > the context of the job (the nodes need to be submit hosts though): > [...] That's unfortunately not the case, but sounds very interest- ing for other applications. Fritz Ferstl <[email protected]> wrote: > And here is something even more straight forward, Tim: > qhost -j -xml | grep qinstance | grep <your_job_ID> > This gives you a single line looking like this > <jobvalue jobid='88' name='qinstance_name'>[email protected]</jobvalue> > If you add an sed command as follows then you even get the > hostname directly: > qhost -j -xml | grep qinstance | grep <your_job_ID> | sed > "s%^.*@\([^<]*\)<.*%\1%" > In "qhost -j" (without the -xml) the length of the hostname > field is limited to 21 characters. So even that might be > enough. > [...] I just learned (*1) about xmllint's --xpath option that re- ally makes that a lot more plainly :-): | tools.wikilint@tools-login:~$ qstat -xml | xmllint --xpath "substring-after(/job_info/queue_info/job_list[@state = 'running' and JB_name = 'lighttpd-wikilint']/queue_name/text(), '@')" -; echo | tools-webgrid-01.eqiad.wmflabs | tools.wikilint@tools-login:~$ Interestingly, "qstat -j lighttpd-wikilint -xml" doesn't produce valid XML: | tools.wikilint@tools-login:~$ qstat -j lighttpd-wikilint -xml | xmllint - | -:84: namespace error : Failed to parse QName 'JATASK:' | <JATASK: 1897.> | ^ | [...] | tools.wikilint@tools-login:~$ But in my use case the output of qstat is never long enough to have to worry about selecting the jobs of interest in the XML parser. Thanks, Tim (*1) Silly me had used "echo cat $XPATHEXPRESSION | xmllint --shell" for years without realizing that xmllint had become much more user-friendly :-). _______________________________________________ users mailing list [email protected] https://gridengine.org/mailman/listinfo/users
