# $PBS\_JOBID variable

**URL:** <https://community.openpbs.org/t/pbs-jobid-variable/176>\
**Category:** Users/Site Administrators\
**Created:** [July 20, 2016, 8:07pm UTC](https://community.openpbs.org/t/pbs-jobid-variable/176 "2016-07-20T20:07:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sscluster](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@sscluster](https://community.openpbs.org/u/sscluster)\
**Post date:** [July 20, 2016, 8:07pm UTC](https://community.openpbs.org/t/pbs-jobid-variable/176/1 "2016-07-20T20:07:06Z")

</div>

PBSpro: 14.10.1  
CentOS 7

Attempting to use the $PBS\_JOBID variable in my job submission script as part of the the output and error file name, but when then files are generated the variable is not resolved and the filename is just outputfilename.$PBS\_JOBID instead of the actual ID.  
I am setting it up in the submission script as follows:

#PBS -e /DIRECTORY/job-err.$PBS\_JOBID  
#PBS -o /DIRECTORY/job-log.$PBS\_JOBID

This has worked for me in a torque installation, but cannot seem to get it to work with PBSpro. Also as a test I echo the variable later in the file with:

echo $PBS\_JOBID

the correct output is generated and put into the job-log.$PBS\_JOBID file.

Any ideas?

-SS-

---

<div class="post-metadata">

**Author:** ![mkaro](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/mkaro/32/85_2.png) [@mkaro](https://community.openpbs.org/u/mkaro)\
**Post date:** [July 21, 2016, 3:38pm UTC](https://community.openpbs.org/t/pbs-jobid-variable/176/2 "2016-07-21T15:38:36Z")

</div>

I don’t recall PBS Pro ever supporting the functionality you mentioned. As a workaround, you could submit the job in held state (qsub -h) and capture the job ID returned. Then qalter the output and error paths. Release the hold on the job using qrls. These steps could be done in a wrapper script.

---

<div class="post-metadata">

**Author:** ![sscluster](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@sscluster](https://community.openpbs.org/u/sscluster)\
**Post date:** [July 21, 2016, 3:46pm UTC](https://community.openpbs.org/t/pbs-jobid-variable/176/3 "2016-07-21T15:46:18Z")

</div>

Michael,  
Thank you for the information. I guess with my other installs since I was using a combo of Torque and Maui the PBS\_JOBID was accessible to me within the submission script.

---

<div class="post-metadata">

**Author:** ![gabe](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@gabe](https://community.openpbs.org/u/gabe)\
**Post date:** [July 22, 2016, 7:53pm UTC](https://community.openpbs.org/t/pbs-jobid-variable/176/4 "2016-07-22T19:53:55Z")

</div>

PBS\_JOBID is accessible within the script, but environment variables are not resolved when they’re in the #PBS directives.

Gabe

---

<div class="post-metadata">

**Author:** ![sscluster](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@sscluster](https://community.openpbs.org/u/sscluster)\
**Post date:** [July 22, 2016, 8:01pm UTC](https://community.openpbs.org/t/pbs-jobid-variable/176/5 "2016-07-22T20:01:26Z")

</div>

Thank you for the update. I’ve decided to not set the -o and -e PBS variables and just let the default filenames be used.
