Last active
December 19, 2015 16:49
-
-
Save bcbwilla/5986535 to your computer and use it in GitHub Desktop.
This script is an improved version of the PBS 'qstat' command that prints out only USEFUL job information (like the FULL name) in a readable way. All of the output of the command 'qstat -f' is captured and organized, so it would be very easy to print out additional info by modifying the last loop of the script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# | |
# This script is an improved version of the 'qstat' command | |
# that prints out only USEFUL information (like the job's | |
# FULL name) in a readable way. | |
# | |
# All of the output of the command 'qstat -f' is captured | |
# and organized, so it would be very easy to print out | |
# additional info by modifying the last loop of the script. | |
# | |
import subprocess | |
# get user name | |
user = subprocess.check_output(['whoami']).strip() | |
# get all jobs data | |
out = subprocess.check_output(['qstat','-f']) | |
lines = out.split('\n') | |
# build list of jobs, each job is a dictionary | |
jobs = [] | |
for line in lines: | |
if "Job Id:" in line: # new job | |
job = {} | |
s = line.split(":") | |
job_id = s[1].split('.')[0].strip() | |
job[s[0].strip()] = job_id | |
if '=' in line: | |
s = line.split("=") | |
job[s[0].strip()] = s[1].strip() | |
elif line == '': | |
jobs.append(job) | |
# print out useful information about user's jobs | |
print "\n " + user + "'s jobs:\n" | |
for job in jobs: | |
if job['Job_Owner'].split('@')[0] == user: | |
print " " + job['Job_Name'] | |
print " Id: " + job['Job Id'] | |
print " Wall time: " + job['resources_used.walltime'] | |
print " State: " + job['job_state'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment