Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use qdel to delete all my jobs at once, not one at a time

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.

like image 325
Gabriel Avatar asked Mar 04 '15 15:03

Gabriel


People also ask

How do I delete a job on PBS?

A job is deleted by sending a Delete Job batch request to the batch server that owns the job. A job that has been deleted is no longer subject to management by batch services. A batch job may be deleted by its owner, the batch operator, or the batch administrator.

How do I cancel QSUB?

Use the qdel command to cancel jobs, regardless of whether the jobs are running or are spooled. Use the qmod command to suspend and resume (unsuspend) jobs already running. For both commands, you need to know the job identification number, which is displayed in response to a successful qsub command.


7 Answers

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

qselect -u <username> | xargs qdel

Worked flawlessly.

like image 136
Gabriel Avatar answered Sep 27 '22 23:09

Gabriel


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

like image 40
Y. Boursin Avatar answered Sep 27 '22 23:09

Y. Boursin


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

like image 35
asifzuba Avatar answered Sep 28 '22 01:09

asifzuba


Try

$ qdel {id1..id2}

So for example:

$ qdel {1148613..1148650}
like image 45
CiaranWelsh Avatar answered Sep 28 '22 01:09

CiaranWelsh


For UGE:

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

like image 40
teng_wenxuan Avatar answered Sep 28 '22 00:09

teng_wenxuan


# 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
like image 39
Jason Avatar answered Sep 28 '22 00:09

Jason


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!

like image 20
guhur Avatar answered Sep 28 '22 01:09

guhur