[GE users] Setting TMPDIR for interactive sessions over SSH.

kisielk kamil at zymeworks.com
Fri Feb 5 00:22:26 GMT 2010


> Am 02.02.2010 um 18:55 schrieb kisielk:
> 
> > Has anyone come up with a way to set the TMPDIR environment  
> > variable for interactive sessions?
> >
> > My interactive sessions are configured as follows:
> > qlogin_command               /usr/local/bin/ssh_wrapper
> > qlogin_daemon                /usr/sbin/sshd -i
> > rlogin_command               /usr/bin/ssh -Y
> > rlogin_daemon                /usr/sbin/sshd -i
> > rsh_command                  /usr/bin/ssh -Y
> > rsh_daemon                   /usr/sbin/sshd -i
> >
> > (where ssh_wrapper is basically ssh -Y -p $2 $1)
> >
> > It seems sge_execd still creates the temporary directory, but I  
> > can't figure out a way to inform the user environment of its location.
> 
> As you get a fresh shell, no environent variable is set. What you can  
> do, is to check the parents of the actual session in your ~/.profile  
> or alike:
> 
> MYPARENT=`ps -p $$ -o ppid --no-header`
> MYPARENT=`ps -p $MYPARENT -o ppid --no-header` # These two lines only  
> for ssh
> MYPARENT=`ps -p $MYPARENT -o ppid --no-header` # These two lines only  
> for ssh
> MYSTARTUP=`ps -p $MYPARENT -o command --no-header`
> 
> if [ "${MYSTARTUP:0:13}" = "sge_shepherd-" ]; then
>     echo "Running inside SGE"
>     MYJOBID=${MYSTARTUP:13}
>     MYJOBID=${MYJOBID% -bg}
>     echo "Job $MYJOBID"
> 
>     . /var/spool/sge/$HOSTNAME/active_jobs/$MYJOBID.1/environment
>     unset HISTFILE
> fi
> 
> With this snippet you get:
> 
> reuti at pc15370:~> qrsh
> Last login: Wed Feb  3 11:48:21 2010 from pc15370.chemie.uni-marburg.de
> Have a lot of fun...
> Running inside SGE
> Job 411
> reuti at pc15381:~> echo $TMPDIR
> /tmp/411.1.all.q
> 
> For the builtin startup leave the two assignments of MYPARENT out. A  
> generic solution would just parse the complete proecss tree up to one  
> without parent.
> 
> -- Reuti
> 

Thanks for putting me on the right track. The approach you show is a good start but unfortunately it doesn't export the variables in to the environment (this is particularly important for TMPDIR) and overwrites some other important variables set by ssh (most notably DISPLAY). I ended up modifying your script to export the TMPDIR and SGE_* variables in to environment, leaving the rest untouched:

# Find the job ID by looking at the sge_shepherd process
MYPARENT=`ps -p $$ -o ppid --no-header`
MYPARENT=`ps -p $MYPARENT -o ppid --no-header`
MYPARENT=`ps -p $MYPARENT -o ppid --no-header`
MYSTARTUP=`ps -p $MYPARENT -o command --no-header`
if [ "${MYSTARTUP:0:13}" = "sge_shepherd-" ]; then
    echo -n "Entering SGE interactive session: "
    MYJOBID=${MYSTARTUP:13}
    MYJOBID=${MYJOBID% -bg}
    echo "Job ${MYJOBID}"

    # Source parts of the sge_shepherd's environment file and export them in to our environment
    SGE_SPOOL=/opt/sge/default/spool
    ENVFILE=${SGE_SPOOL}/${HOSTNAME}/active_jobs/${MYJOBID}.1/environment
    source <(sed -n -e 's/^SGE_\|^TMPDIR/export &/p' $ENVFILE)
fi

------------------------------------------------------
http://gridengine.sunsource.net/ds/viewMessage.do?dsForumId=38&dsMessageId=243372

To unsubscribe from this discussion, e-mail: [users-unsubscribe at gridengine.sunsource.net].



More information about the gridengine-users mailing list