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.

3
  • is this NQS queuing system?
    – Sigi
    Mar 4, 2015 at 15:14
  • @Sigismondo sorry, I'm not sure what that means. I have very little knowledge with cluster managing (which I don't), I just use it.
    – Gabriel
    Mar 4, 2015 at 15:15
  • why does qdel -u <username> fail? Oct 14, 2020 at 16:04

9 Answers 9

107

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

qselect -u <username> | xargs qdel

Worked flawlessly.

8
  • Is there a way how to skip completed jobs? This solution does work, but outputs a great portion of errors of qdel trying to kill completed jobs.. Apr 16, 2016 at 9:53
  • Mmm I don't really know, sorry.
    – Gabriel
    Apr 16, 2016 at 13:22
  • 3
    Thanks. Just in addition for UGE the option is up-case: qselect -U <user_list> Oct 23, 2017 at 15:31
  • 1
    link is back online
    – dter
    Mar 10, 2018 at 0:39
  • 2
    Use $USER for <username>
    – SmallChess
    Jun 13, 2018 at 4:05
60

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

2
  • why does qdel -u <username> fail? Oct 14, 2020 at 16:04
  • the second solution did not work for me... Nov 21, 2021 at 19:04
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

3
  • 2
    I use this all of the time because it adds a lot of flexibility for other grep searches.
    – eclark
    Jul 14, 2017 at 21:21
  • why does qdel -u <username> fail? Oct 14, 2020 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. Jun 28, 2021 at 16:45
8

Try

$ qdel {id1..id2}

So for example:

$ qdel {1148613..1148650}
4

For UGE:

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

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
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!

2
  • 3
    Doesn't work for me. The job all of user(s) <user> does not exist. Jul 7, 2016 at 16:57
  • Works for me. Even if the system reports "unauthorized," it does as guhur states and deletes only your jobs.
    – Ghersic
    Jul 25, 2019 at 20:45
-1
qstat | cut -d. -f1 | sed "s;   \(.*\) 0;qdel \1;" | bash

sed's power.

-2

Just use the following command:

qdel all           

It will cancel all jobs running on cluster.

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.