Reputation: 3919
I am having an issue where if I have 2000 jobs queued and try to delete them with qdel all
, it'll keep trying to delete the running jobs first. This means I have to wait a long time for the jobs to get deleted because removing from the Running
list is slower than Idle
list.
Thus how do I remove all Idle
jobs without touching the Running
jobs?
Upvotes: 6
Views: 2312
Reputation: 16711
If the job ids are in sequential order, you could use Bash's brace extension. For example:
$ echo {0..9}
0 1 2 3 4 5 6 7 8 9
Transferred to delete all jobs ranging from 1000 to 2000, the qdel
command would be:
qdel {1000..2000}
This might even work if there are job ids that you are not allowed to delete (from other users). They should be simply ignored. (not tested)
Upvotes: 2
Reputation: 836
If you prefer to use the a shell script you can set up something like that below. If your idle jobs are in numeric order this is the most straightforward solution that doesn't rely on having the proper variables set in torque.
#!/bin/csh
# delete the range of jobs via counter i
module load torque
module load maui
set i = 1351208
while ( $i < 1351668 )
qdel $i
@ i++
end
Upvotes: 0
Reputation: 3919
Python:
import os
import subprocess
cmd = [ 'showq' ]
output = subprocess.Popen( cmd, stdout=subprocess.PIPE ).communicate()[0]
jobid = [int(s) for s in output.split() if s.isdigit()]
jobid2 = []
for i in jobid:
if i > 100000:
jobid2 += [i]
jobid2.sort()
jobid2.reverse()
#jobid2 = jobid2[2000:3000]
for i in jobid2:
print len(jobid2)
os.system('qdel ' + str(i))
Upvotes: 0