Sections
In this section
Computational Science and Engineering

174 Geology/Physics
UC Davis
One Shields Avenue
Davis, CA 95616

(530) 752-6298 phone
(530) 752-8894 fax

 
Computational Science and Engineering > Help > FAQs > How do I export environment variables to a compute job?
Personal tools

How do I export environment variables to a compute job?

Up to Table of Contents

How do I export an environment variable like LD_LIBRARY_PATH to a job that runs on a CSE-managed cluster?

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...