Parsa
Parsa

Reputation: 3236

Pass environment variable to qsub jobs

I want to add a string to the PATH environment variable of a qsub command. Editing the .sh file is not an option because this is generated and run within the pipeline (I can edit the qsub command options).

I am running the following qsub command:

qsub -pe slots 16 -S /bin/bash -cwd -N "pipeline" -j y -o /home/user/log/out.log /home/user/pipeline/runthis.sh

I need to add the following PATH environment variable to the shell being run:

/home/user/jre1.8.0_66/bin

(this is because the script depends on a more recent version of java than is on the cluster).

I tried the following:

qsub -pe slots 16 -S /bin/bash -cwd -N "pipeline" -j y -o /home/user/log/out.log /home/user/pipeline/runthis.sh -v PATH=/home/pa354/jre1.8.0_66/bin:$PATH -V

This hasn't worked, I added 'env' to the bash file being run (to check the environment variables), my required path has not been added.

Upvotes: 1

Views: 8721

Answers (1)

John Zwinck
John Zwinck

Reputation: 249153

You need to use -v in your qsub command:

qsub -v JAVA_HOME ...

This will pass along the environment variable from the calling environment into the spawned job.

Note that the -v argument to qsub must come before the arguments to the actual command you are running on the remote nodes. You seem to have tried it at the end of the entire command line which isn't going to work.

Upvotes: 5

Related Questions