Question

I'm working with a computation cluster that uses PBS/Torque for job scheduling. The queue can be pretty long at times, for example, I now have a few jobs submitted in a queue of over 800 (as reported by showq which shows a full list of jobs, but as far as I am aware these aren't necessarily in the order of execution).

I would like to find out where in the queue my jobs are located; how many will be processed before mine? I would like to get some output like: Job <id>: 417/862. This way I would have at least some indication of progress and waiting time. However, I have not been able to find out how to do this. Can it be done, and how?

Was it helpful?

Solution

I wasn't sure if I could count on it that queued jobs would be executed in the order presented by showq, but after some more research, it certainly looks like it.

The queue printed by showq has the following format:

ACTIVE JOBS--------
[table headers]
[listing of active jobs]
IDLE JOBS--------
[table headers]
[listing of idle jobs]
BLOCKED JOBS----------
[table headers]
[listing of blocked jobs]

Based on this format, I came up with the following bash script to find a job's place in the idle section of the queue, given the job's id:

job=$1

idlestart=`showq | grep "IDLE JOBS" -n | cut -d: -f1`

jobline=`showq | grep -n $job | cut -d: -f1`
place=`expr $jobline - $idlestart - 2`

echo "Idle Jobs section starts at line $idlestart"
echo "Job $job at line $jobline"
echo "Place in queue: $place"

Example output:

$ ./placeinq 6565618 

Idle Jobs section starts at line 343
Job 6565618 at line 387
Place in queue: 42
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top