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