Get walltime in a PBS job script

2020-04-05 09:14发布

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

标签: pbs
2条回答
姐就是有狂的资本
2楼-- · 2020-04-05 09:39

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.

查看更多
forever°为你锁心
3楼-- · 2020-04-05 09:46

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.

查看更多
登录 后发表回答