4

I know commands, like qsub, qstat -a, qstat -an, etc.

But how can I find how many jobs a single user has in the queue (not all necessarily running) at any given time?

bwDraco
  • 45,747
  • 43
  • 165
  • 205
Jackson Hart
  • 303
  • 1
  • 4
  • 16

3 Answers3

11

I think you're looking for the 'user' option of qstat. qstat -u username lists all jobs belonging to the given user. Wildcards can be included with a backslash: qstat -u \\* lists all jobs.

To answer your specific question (total jobs), you can use wc to count the lines that qstat outputs:

qstat -u username | wc -l

But that will give two more than the actual jobs because qstat has two header lines. So the full command you may want is:

expr $(qstat -u username | wc -l) - 2

Which asks for the jobs by user username, counts the numbers of lines, and subtracts 2.

Ross
  • 148
  • 2
  • 10
3

Number of header lines may be different from 2 (e.g., on our Cray it is 5). Another solution is:

qselect -u username | wc -l

qselect does not produce header lines.

user2052436
  • 131
  • 2
1

An actual solution is qstat -u username |grep username |wc -l this way the number of header lines does not matter.

  • Since the answer is already accepted. you may take this solution and put it as a comment inside the accepted answer port to compliment it. – p._phidot_ Jun 15 '21 at 10:19