Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get walltime in a PBS job script

Tags:

pbs

When submitting a job script to a PBS queuing system, a walltime is specified automatically or by the user e.g. via

#PBS -l walltime=1:00:00

The question is if this time can be accessed from the job script. Is there an environment variable or some other way to get this walltime.

In the end, the job script should decide from time to time if there is enough time left to do some more work so that the job does not get killed by the queuing system.

Update:

At least if the user has specified the walltime in the resources list, I can propose the following workaround (working for bash)

read _ _ PBS_WALLTIME  <<< `qstat -f $PBS_JOBID | grep "Resource_List.walltime"`

which parses the walltime from the qstat output and places the value in the PBS_WALLTIME variable. Accordingly, the command

echo $PBS_WALLTIME

will yield something like

1:00:00
like image 226
dastrobu Avatar asked Apr 05 '13 13:04

dastrobu


2 Answers

This is stored in the environment variable $PBS_WALLTIME.

Of course, that is for TORQUE, I'm not sure which PBS queuing system you are using.

like image 199
dbeer Avatar answered Oct 05 '22 14:10

dbeer


I was looking for an answer to this and the comments above gave me an idea that seems to work pretty well. You can use qstat and grab the pertinent information from it with sed:

qstat -f $PBS_JOBID | sed -rn 's/.*Resource_List.walltime = (.*)/\1/p'

Putting this in your PBS script will print out the value and you can use standard bash to store the output of this in a variable:

WALLTIME=$(qstat -f $PBS_JOBID | sed -rn 's/.*Resource_List.walltime = (.*)/\1/p')

You can also use this to get other information that is not available from the PBS_* environment variables such as the amount of memory allocated for the job and probably some other stuff.

like image 44
StFS Avatar answered Oct 05 '22 13:10

StFS