PBS Command : I'm using the following command " qstat -an -1 -w ``'qselect -q quename -l resourcelist' , If it doesnt find any valid job, it is printing all jobs in the q. Any work around available?

I'm using the following command " qstat -an -1 -w ``'qselect -q quename -l resourcelist' , If it doesnt find any valid job, it is printing all jobs in the q. Any work around available to print "none" when it doesnt find any jobs that satisfy my filter?
Best Answer
-
qselect acts much like an SQL select statement; you can simply call it to check what is output before putting through another command like qstat or qdel. Unfortunately, if it returns nothing, you get no parameters passed to qstat command to limit the search.
Probably the quick and dirty way of accomplishing what you need is to run it through a bash "if not empty" operation. Something like:
[ ! -z `qselect -q workq -l ncpus.gt.2`] && qstat -n1w `qselect -q workq -l ncpus.gt.2`
This isn't the cleanest method, but gets the job done.
1
Answers
-
qselect acts much like an SQL select statement; you can simply call it to check what is output before putting through another command like qstat or qdel. Unfortunately, if it returns nothing, you get no parameters passed to qstat command to limit the search.
Probably the quick and dirty way of accomplishing what you need is to run it through a bash "if not empty" operation. Something like:
[ ! -z `qselect -q workq -l ncpus.gt.2`] && qstat -n1w `qselect -q workq -l ncpus.gt.2`
This isn't the cleanest method, but gets the job done.
1