Skip to content

Instantly share code, notes, and snippets.

@wckdouglas
Created August 28, 2015 17:10
Show Gist options
  • Save wckdouglas/4490ebc279b63f4b23d6 to your computer and use it in GitHub Desktop.
Save wckdouglas/4490ebc279b63f4b23d6 to your computer and use it in GitHub Desktop.
Job simitting
#!/bin/env python
import commands
import glob
import time
import os
import sys
maxJobLim = 46
joblist = glob.glob('./job_*.sge')
command = 'qstat | grep $USER |wc -l'
p = commands.getstatusoutput(command)
jobnum = int(p[1])
log = 'submittedList.txt'
logging = open(log,'w')
for i in range(len(joblist)):
p = commands.getstatusoutput(command)
jobnum = int(p[1])
logging.write('Current job number: %i\n' %jobnum)
if jobnum < maxJobLim:
submit = 'qsub %s ' %(joblist[i])
os.system(submit)
logging.write('submitted: '+joblist[i]+'\n')
else:
while jobnum > maxJobLim:
time.sleep(600)
p = commands.getstatusoutput(command)
jobnum = int(p[1])
submit = 'qsub %s ' %(joblist[i])
os.system(submit)
logging.write('submitted: '+joblist[i]+'\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment