By default, output from a submitted job to a Torque queue will be saved to a file named like job_name.o658392
. What I want to do, using that example, is to name the output file 658392.job_name.log
instead.
I know I can specify the name of the output file by writing the line #PBS -e filename
at the top of my script, and it is even possible to use variables such as $PBS_JOBID
in the filename.
The problem is that $PBS_JOBID
is not just the number - instead it looks like 658392.some.very.long.host.name
.
I've tried using ${PBS_JOBID/.*}
, which should refer only to the numbers, but the problem is that I get an error doing this. It reads: Failed to expand destination path in data staging: /path/to/output/${PBS_JOBID/.*}.log
Do you know how to specify the output file name in a way that works?
If you are an admin, you could get this to be just the numeric job id by setting
qmgr -c 'set server display_job_server_suffix = false'
Of course, if you change this setting you want to do it when you don't have jobs queued.
If you are a normal user- I have not tested this - but I believe that if you add a variable to the job's environment you can use that variable in the job's output file. If you wanted to, you can make a variable called numeric_jobid and add that to the job's environment, and then you can use that in the job's output file. I believe you can have the following lines in job_script:
#PBS -j oe
#PBS -o $numeric_jobid
Then
jobid=`qsub job_script`
numeric_id=`get just the numeric id from $jobid`
qalter $jobid -v numeric_id=$numeric_id
EDIT: you can save a step with this:
qalter -o $numeric_id.log $jobid
And I believe that would allow you to do it.