When I submit a bunch of jobs using qsub, the qsub will source the .bash_profile at first. So how can I qsub a job without source .bash_profile firstly.
-
Why is it important for you to avoid loading the bash_profile? – John Zwinck Mar 24 '12 at 02:48
-
1I want to write a qsub script for public use, but maybe the bash_profile or bashrc of some people's local env. will conflict with the qsub job. – user1289405 Mar 24 '12 at 03:35
2 Answers
I think there are a number of different qsub
commands, associated with different batch systems. It would be useful to tell us which batch system you're using.
As I recall, most such systems set one or more environment variables that you can test in your .bash_profile
. The systems I've used either set $ENVIRONMENT
to "BATCH"
, or set $PBS_ENVIRONMENT
to "PBS_BATCH"
. (Those may be obsolete; check your documentation.)
You could modify your .bash_profile
to do something like this:
if [ "$ENVIRONMENT" != "BATCH" ] ; then
# existing code here
fi
So your .bash_profile
is still sourced, but it doesn't do anything if it's running in a batch environment.
This is easy to modify so some commands are still executed.

- 254,901
- 44
- 429
- 631
If you can figure out how to pass arguments to bash itself, the one you're looking for is --noprofile
. But I'm not familiar with qsub, and a quick glance at the manual for it didn't clue me in on how to do this. Can you specify what shell your job runs under somehow?

- 239,568
- 38
- 324
- 436
-
qsub has one option -S "The -S option allows users to specify the program (usually a shell) that will be invoked to process the script of the batch job." Maybe I can use "qsub -S /bin/bash --noprofile", but the qsub cannot recognize the space beween /bin/bash and --noprofile. – user1289405 Mar 24 '12 at 03:24
-
Did you try `qsub -S '/bin/bash --noprofile'`? (using quotes to make the argument to -S be just one string? I am not certain it will work, but it may. – John Zwinck Mar 24 '12 at 09:46