IBM Support

A script to query job information through Python API

How To


Summary

Here is an example script to query job information using Python API.

$cat job_info.py
from pythonlsf import lsf

def job_info():
"""
Query a job...
"""
if lsf.lsb_init("test") > 0:
exit(1)

i=lsf.lsb_openjobinfo(0,'','user_name','','',0x0040)
arg = lsf.new_intp()
lsf.intp_assign(arg, i);
jobinfo=lsf.lsb_readjobinfo(arg)
print(jobinfo.jobId)
print(jobinfo.status)
print(jobinfo.user)
lsf.lsb_closejobinfo()
return jobinfo.jobId

if __name__ == '__main__':
print("LSF Clustername is :", lsf.ls_getclustername())
print(job_info())

Test the script:
$bjobs
JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME
5538 user_name RUN normal host1 host2 *sleep 100 Oct 31 05:31

$python job_info.py
('LSF Clustername is :', 'lsf10.1')
5539
4
user_name
5539

[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSWRJV","label":"IBM Spectrum LSF"},"Component":"","Platform":[{"code":"PF016","label":"Linux"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB77","label":"Automation Platform"}}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

Modified date:
22 November 2018

UID

ibm10738933