Question

I use the SUN's SGE to submit my jobs into a cluster system. The problem is how to let the computing machine find the environment variables in the host machine, or how to config the qsub script to make the computing machine load the environment variables in host machine? The following is an script example, but it will say some errors, such as libraries not found:

    #!/bin/bash
    #
    #$ -V
    #$ -cwd
    #$ -j y
    #$ -o /home/user/jobs_log/$JOB_ID.out
    #$ -e /home/user/jobs_log/$JOB_ID.err
    #$ -S /bin/bash
    #

    echo "Starting job: $SGE_TASK_ID"

    # Modify this to use the path to matlab for your system
    /home/user/Matlab/bin/matlab -nojvm -nodisplay -r matlab_job 

    echo "Done with job: $SGE_TASK_ID"
Was it helpful?

Solution

The technique you are using (adding a -V) should work. One possibility since you are specifying the shell with -S is that grid engine is configured to launch /bin/bash as a login shell and your profile scripts are stomping all over the environment you are trying to pass to the job.

Try using qstat -xml -j on the job while it is queued/running to see what environment variables grid engine is trying to pass to the job.

Try adding an env command to the script to see what variables are set.

Try adding shopt -q login_shell;echo $? in the script to tell you if it is being run as a login shell.

To list out shells that are configured as login shells in grid engine try:

SGE_SINGLE_LINE=true qconf -sconf|grep ^login_shells

OTHER TIPS

I think this issue is due to you didn't config BASH in the login_shells of SGE check your login_shells by qconf -sconf and see if bash in there.

login_shells UNIX command interpreters like the Bourne-Shell (see sh(1)) or the C- Shell (see csh(1)) can be used by Grid Engine to start job scripts. The command interpreters can either be started as login-shells (i.e. all system and user default resource files like .login or .profile will be executed when the command interpreter is started and the environment for the job will be set up as if the user has just logged in) or just for command execution (i.e. only shell specific resource files like .cshrc will be executed and a minimal default environment is set up by Grid Engine - see qsub(1)). The parameter login_shells contains a comma separated list of the executable names of the command inter- preters to be started as login-shells. Shells in this list are only started as login shells if the parameter shell_start_mode (see above) is set to posix_compliant.

   Changes to login_shells will take immediate effect.   The  default  for
   login_shells is sh,csh,tcsh,ksh.

   This value is a global configuration parameter only. It cannot be over-
   written by the execution host local configuration.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top