How to use qdel all to remove only idle jobs
Asked Answered
J

3

6

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?

Jada answered 16/1, 2014 at 1:27 Comment(1)
Please paste a few lines and the header of qstat output with your usual combination of options. By parsing this output you can usually extract exactly the IDs of the jobs you wish to delete.Leeds
P
2

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)

Pang answered 11/3, 2015 at 15:53 Comment(0)
J
0

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))
Jada answered 17/1, 2014 at 15:9 Comment(0)
R
0

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
Rehash answered 8/1, 2015 at 17:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.