2

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.

user1289405
  • 31
  • 1
  • 3

2 Answers2

2

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.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
0

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?

John Zwinck
  • 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