How do I export environment variables to a compute job?
Up to Table of Contents
Since we use batch queues at CSE your environment may be different once your job starts running. There are a few ways to export specific environment variables tfor use when your job runs.
Exporting All Environment Variables
If you have your environment set up just as you like it and want to pass on all environment variables to your job you should use the -V option in your submission script. From the qsub man page:
-V Specify that all of the environment variables of the process
are exported to the context of the batch job.
The qsub utility shall place every environment variable in the process
in which the utility is executing in the list and shall set the value
of each variable in the attribute to the value of that variable in the
process.
For example your submission script could look like this:
$ cat submit.sh
#!/bin/bash
#$ -cwd
#$ -S /bin/bash
# export all environment variables
#$ -V
~/bin/foo
Export a Specific Environment Variable
If you do not want to set up your environment every time...