[GE users] SGE 6.2 and qrsh

Andreas Haupt andreas.haupt at desy.de
Fri Oct 17 09:39:17 BST 2008


Hi Reuti,

On Thu, 2008-10-16 at 16:13 +0200, Reuti wrote:
> Hi Andreas,
> 
> when you have an interactive shell on a node, you will find that a  
> "ps -e f" (f w/o -) is like before in 6.0/6.1: a complete fresh shell  
> is started. Hence it doesn't know anything about any variables set  
> before. You could put in your ~/.profile (or ~/.bash_profile):
> 
> MYPARENT=`ps -p $$ -o ppid --no-header`
> 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"
> 
>     . /usr/sge/default/spool/$HOSTNAME/active_jobs/$MYJOBID.1/ 
> environment
> fi
> 
> This will check the whether it's running as a kid of a shepherd and  
> source the environment.

That's a nice idea. But it doesn't work here in reality as the shepherd
doesn't expose the job id in the process list:

[bolek-vm1] ~ % MYPARENT=`ps -p $$ -o ppid --no-header`
[bolek-vm1] ~ % MYSTARTUP=`ps -p $MYPARENT -o command --no-header`
[bolek-vm1] ~ % echo $MYSTARTUP 
/usr/gridengine/bin/lx24-amd64/sge_shepherd -bg

But it brings up a new idea: I can do this in the profiles on exec
hosts:

parent=`ps -p $$ -o ppid --no-header`
ps -p $parent -o command --no-header | grep -q 'sge_shepherd'

if [ $? = 0 ]; then
    for jobdir in /usr/gridengine/default/spool/`hostname -s`/active_jobs/*; do
        jobpid=`cat $jobdir/pid`
        if [ "$jobpid" -eq "$parent" ]; then
            egrep -q '^JOB_SCRIPT=QRLOGIN$' $jobdir/environment
            if [ $? = 0 ]; then
                . $jobdir/environment
                for var in `awk -F = '{print $1}' $SGE_JOB_SPOOL_DIR/environment`; do
                    export $var
                done
            fi
        fi
    done
fi

It helps that we just have one SGE_CELL. I will now adopt this for
(t)csh users and then my problem is actually solved.

Thanks,
Andreas
-- 
| Andreas Haupt             | E-Mail: andreas.haupt at desy.de
|  DESY Zeuthen             | WWW:    http://www-zeuthen.desy.de/~ahaupt
|  Platanenallee 6          | Phone:  +49/33762/7-7359
|  D-15738 Zeuthen          | Fax:    +49/33762/7-7216


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at gridengine.sunsource.net
For additional commands, e-mail: users-help at gridengine.sunsource.net




More information about the gridengine-users mailing list