Current directory ./ in qsub

batch jobsworking directory

It seems that I cannot use ./ in qsub as in

qsub -q hpc-pool ./myScript.sh

where myScript.sh contains several ./.

After checking, ./ somewhat is translated to ~/. Why is this the case?

Best Answer

Batch jobs submitted by qsub are executed in your home directory by default.

Some versions of qsub support the -d option to specify a different directory. To execute the script in the same directory where you ran qsub, use

qsub -d "$PWD" -q hpc-pool ./myScript.sh

If the -d option is not available, you can access the directory where you ran qsub in your script, in the PBS_O_WORKDIR variable. So add this line near the beginning of your script:

cd "$PBS_O_WORKDIR" || exit $?
Related Question