How to include the job id and other info in the output file for qsub?

I want my output stream to be directed to a specific file and I want that file to include the jobid. How does one do this?

My example script that does not work as intended:

#!/homes/miranda9/.conda/envs/automl-meta-learning/bin/python
#PBS -V
#PBS -M brando.science@gmail.com
#PBS -m abe
#PBS -e="experiment_output_job.%j.%N.out"
#PBS -o="experiment_output_job.%j.%N.out"
#PBS -lselect=1:ncpus=30

I’ve tried many combinations of different things but I don’t want to bore you with the failed attempts. What actually works?


related but eventually useless SO question: https://stackoverflow.com/questions/9096959/how-to-specify-error-log-file-and-output-file-in-qsub

Could you please try the below PBS attribut , say save the script as testh.sh

#!/homes/miranda9/.conda/envs/automl-meta-learning/bin/python
#PBS -V
#PBS -M brando.science@gmail.com
#PBS -m abe
#PBS -l select=1:ncpus=30
/bin/hostname
env

Submit the aboe script and you should see the standard out and error , test.sh.o and test.sh.e automatically created by PBS Pro.

so I cannot create a custom name with variable substitution?

Thats correct

PBS_JOBID gets populated once it has been accepted by the PBS Server. Hence, variable substitution would not work in the PBS Directive.