I am using PBS job scheduler on my cluster, and I would like to delete jobs older than a certain date using qdel
; alternatively it would be sufficient to be able to sort the results of qstat
by date.
qstat
gives this output:
job-ID prior name user state submit/start at queue slots ja-task-ID
-----------------------------------------------------------------------------------------------------------------
326539 0.50500 run user r 01/06/2011 11:13:34 [email protected] 1
326594 0.50500 run user r 01/06/2011 11:13:34 [email protected] 1
and I can delete jobs with qdel
:
qdel 326539
and the jobs I want to delete can be located using grep
:
qstat > foo; grep 01/06 foo
my current work around is to paste the output from above into a spreadsheet, sort by job-ID, and then qdel {min..max}
,
Can I combine these steps into a single command?
Assistance appreciated.
qstat | awk '$6 ~ "01/06" {cmd="qdel " $1; system(cmd); close(cmd)}'
#!/bin/bash
match="01/06"
while read job; do
set -- $job
if [[ $6 =~ $match ]]; then
qdel "$1"
fi
done < <(qstat)
If you want to do a dry-run, then change qdel "$1"
to echo qdel "$1"
to see what it would have done.