71

This is a rather simple question but I haven't been able to find an answer.

I have a large number of jobs running in a cluster (>20) and I'd like to delete them all and start over.

According to this site I should be able to just do:

qdel -u netid

to get rid of them all, but in my case that returns:

qdel: invalid option -- 'u'
usage: qdel [{ -a | -c | -p | -t | -W delay | -m message}] [<JOBID>[<JOBID>]|'all'|'ALL']...
   -a -c, -m, -p, -t, and -W are mutually exclusive

which obviously indicates that the command does not work.

Just to check, I did:

qstat -u <username>

and I do get a list of all my jobs, but:

qdel -u <username>

also fails.

Gabriel
  • 40,504
  • 73
  • 230
  • 404

9 Answers9

107

Found the answer buried in an old supercluster.org thread:

qselect -u <username> | xargs qdel

Worked flawlessly.

dter
  • 1,065
  • 2
  • 11
  • 22
Gabriel
  • 40,504
  • 73
  • 230
  • 404
61

Building on what Gabriel answered:

qselect -u <username> | xargs qdel

qselect -u <username> -s <state> | xargs qdel

<state> would be R for running jobs only.

qselect will allow you to select job based on other criterias, like ressources asked (-l), destination queue (-q) ...

qdel -u <username>

will only work with SGE

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Y. Boursin
  • 776
  • 6
  • 11
14

sometimes a simple grep/cut can help too: qstat | grep $USER | cut -d. -f1 | xargs qdel

This way we can also grep on a particular keyword for the jobs and delete them.

HTH

asifzuba
  • 450
  • 3
  • 7
  • 2
    I use this all of the time because it adds a lot of flexibility for other grep searches. – eclark Jul 14 '17 at 21:21
  • why does `qdel -u ` fail? – Charlie Parker Oct 14 '20 at 16:04
  • 2
    You may need to adjust the delimiter and field number depending on what your `qstat` output looks like. For example, for me it starts with two space characters and so I use `qstat | grep $USER | cut -d' ' -f3 | xargs qdel`. – Lino Ferreira Jun 28 '21 at 16:45
8

Try

$ qdel {id1..id2}

So for example:

$ qdel {1148613..1148650}
CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
4

For UGE:

qstat -u | gawk '{print $1}' | xargs qdel

teng_wenxuan
  • 161
  • 6
2
# Delete all jobs owned by the current user.
# 
# Command breakdown:
# ------------------
#
# qselect
# -u selects all jobs that belong to the current user
# -s EHQRTW selects all job states except for Complete
#
# xargs
# --no-run-if-empty Do not run qdel if the result set is empty
#                   to avoid triggering a usage error.
#
# qdel
# -a delete jobs asynchronously
#
# The backslashes are a trick to avoid matching any shell aliases.

\qselect -u $(whoami) -s EHQRTW | \xargs --no-run-if-empty \qdel -a
Jason
  • 89
  • 6
1

Another possibility is to do qdel all. It deletes all jobs from everyone. When you don't have access for other people's job, it deletes only your jobs.

It is not the most beautiful solution, but it is surely the shortest!

guhur
  • 2,500
  • 1
  • 23
  • 33
-1
qstat | cut -d. -f1 | sed "s;   \(.*\) 0;qdel \1;" | bash

sed's power.

MrMimic
  • 15
  • 2
-2

Just use the following command:

qdel all           

It will cancel all jobs running on cluster.

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87