Re: [gridengine users] Fwd: Request: JOB_ID, QUEUE, etc. variables in a QLOGIN session

2018-12-12 Thread Gowtham
It works! THANK YOU!!

The modified code snippet to make it work within the Rocks Cluster
Distribution is as follows:

###
# Reuti / Grid Engine Mailing List
# Wed, 12 Dec 2018 13:13:37 -0500
MYPARENT=$(ps -p $$ -o ppid --no-header)
MYSTARTUP=$(ps -p ${MYPARENT} -o command --no-header)

if [ "${MYSTARTUP:0:13}" = "sge_shepherd-" ]
then
  MYJOBID=${MYSTARTUP:13}
  MYJOBID=${MYJOBID% -bg}

  while read LINE
  do
export ${LINE}
  done <
/opt/gridengine/default/spool/${HOSTNAME%%.*}/active_jobs/${MYJOBID}.1/environment
  unset HISTFILE

  if [ -n "${MYJOBID}" ]
  then
   source /opt/gridengine/default/common/settings.sh
   qstat -j ${MYJOBID} | \
 sed -n -e "/^context/s/^context: *//p" | \
 tr "," "\n" | \
 sed -n -e "s/^MESSAGE=//p"
  fi
fi
###

Best regards,
Gowtham

--
Gowtham, PhD
Director of Research Computing, IT
Research Associate Professor, ECE
Michigan Technological University

P: (906) 487-4096
F: (906) 487-2787
https://it.mtu.edu
https://hpc.mtu.edu


On Wed, Dec 12, 2018 at 1:06 PM Gowtham  wrote:

> Thank you!
>
> I'll try this out and let you know how it goes :)
>
> Best regards,
> Gowtham
>
> --
> Gowtham, PhD
> Director of Research Computing, IT
> Research Associate Professor, ECE
> Michigan Technological University
>
> P: (906) 487-4096
> F: (906) 487-2787
> https://it.mtu.edu
> https://hpc.mtu.edu
>
>
> On Wed, Dec 12, 2018 at 12:52 PM Reuti  wrote:
>
>> Hi,
>>
>> > Am 12.12.2018 um 17:50 schrieb Gowtham :
>> >
>> > Greetings.
>> >
>> > I am wondering if there's a way to access JOB_ID, QUEUE and other such
>> SGE variables from within a QLOGIN session. For example,
>> >   • I type 'qlogin' and gain access to one of the compute nodes.
>> >   • Running 'qstat -u ${USER}' lists this QLOGIN session with a
>> 'job-ID'
>> >   • The command, echo ${JOB_ID}, returns blank from within that
>> QLOGIN session instead of showing the number displayed in #2.
>> > Please let me know if there's a way to achieve this.
>>
>> The shell you get performed a fresh startup and does not know anything
>> about the formerly set environment variables by the sgeexecd.
>>
>> I have this snippet below, please put it in your ~/.bash_profile. resp.
>> ~/.profile; whichever you prefer and use. The number of MYPARENT
>> assignments depends on the method you started the session: rsh, ssh or
>> built-in. IIRC the last `if [ -n "$MYJOBID" ];` section had only the
>> purpose to display a message, which was set with "-ac" during submission
>> and might not be necessary here.
>>
>> -- Reuti
>>
>> 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 "Running inside SGE"
>>MYJOBID=${MYSTARTUP:13}
>>MYJOBID=${MYJOBID% -bg}
>>echo "Job $MYJOBID"
>>
>>while read LINE; do export $LINE; done <
>> /var/spool/sge/${HOSTNAME%%.*}/active_jobs/$MYJOBID.1/environment
>>unset HISTFILE
>>
>>if [ -n "$MYJOBID" ]; then
>>   . /usr/sge/default/common/settings.sh
>>qstat -j $MYJOBID | sed -n -e "/^context/s/^context: *//p" | tr
>> "," "\n" | sed -n -e "s/^MESSAGE=//p"
>>fi
>> fi
>>
>
___
users mailing list
users@gridengine.org
https://gridengine.org/mailman/listinfo/users


Re: [gridengine users] Fwd: Request: JOB_ID, QUEUE, etc. variables in a QLOGIN session

2018-12-12 Thread Gowtham
Thank you!

I'll try this out and let you know how it goes :)

Best regards,
Gowtham

--
Gowtham, PhD
Director of Research Computing, IT
Research Associate Professor, ECE
Michigan Technological University

P: (906) 487-4096
F: (906) 487-2787
https://it.mtu.edu
https://hpc.mtu.edu


On Wed, Dec 12, 2018 at 12:52 PM Reuti  wrote:

> Hi,
>
> > Am 12.12.2018 um 17:50 schrieb Gowtham :
> >
> > Greetings.
> >
> > I am wondering if there's a way to access JOB_ID, QUEUE and other such
> SGE variables from within a QLOGIN session. For example,
> >   • I type 'qlogin' and gain access to one of the compute nodes.
> >   • Running 'qstat -u ${USER}' lists this QLOGIN session with a
> 'job-ID'
> >   • The command, echo ${JOB_ID}, returns blank from within that
> QLOGIN session instead of showing the number displayed in #2.
> > Please let me know if there's a way to achieve this.
>
> The shell you get performed a fresh startup and does not know anything
> about the formerly set environment variables by the sgeexecd.
>
> I have this snippet below, please put it in your ~/.bash_profile. resp.
> ~/.profile; whichever you prefer and use. The number of MYPARENT
> assignments depends on the method you started the session: rsh, ssh or
> built-in. IIRC the last `if [ -n "$MYJOBID" ];` section had only the
> purpose to display a message, which was set with "-ac" during submission
> and might not be necessary here.
>
> -- Reuti
>
> 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 "Running inside SGE"
>MYJOBID=${MYSTARTUP:13}
>MYJOBID=${MYJOBID% -bg}
>echo "Job $MYJOBID"
>
>while read LINE; do export $LINE; done <
> /var/spool/sge/${HOSTNAME%%.*}/active_jobs/$MYJOBID.1/environment
>unset HISTFILE
>
>if [ -n "$MYJOBID" ]; then
>   . /usr/sge/default/common/settings.sh
>qstat -j $MYJOBID | sed -n -e "/^context/s/^context: *//p" | tr ","
> "\n" | sed -n -e "s/^MESSAGE=//p"
>fi
> fi
>
___
users mailing list
users@gridengine.org
https://gridengine.org/mailman/listinfo/users


Re: [gridengine users] Fwd: Request: JOB_ID, QUEUE, etc. variables in a QLOGIN session

2018-12-12 Thread Reuti
Hi,

> Am 12.12.2018 um 17:50 schrieb Gowtham :
> 
> Greetings.
> 
> I am wondering if there's a way to access JOB_ID, QUEUE and other such SGE 
> variables from within a QLOGIN session. For example, 
>   • I type 'qlogin' and gain access to one of the compute nodes.
>   • Running 'qstat -u ${USER}' lists this QLOGIN session with a 'job-ID'
>   • The command, echo ${JOB_ID}, returns blank from within that QLOGIN 
> session instead of showing the number displayed in #2. 
> Please let me know if there's a way to achieve this.

The shell you get performed a fresh startup and does not know anything about 
the formerly set environment variables by the sgeexecd.

I have this snippet below, please put it in your ~/.bash_profile. resp. 
~/.profile; whichever you prefer and use. The number of MYPARENT assignments 
depends on the method you started the session: rsh, ssh or built-in. IIRC the 
last `if [ -n "$MYJOBID" ];` section had only the purpose to display a message, 
which was set with "-ac" during submission and might not be necessary here.

-- Reuti

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 "Running inside SGE" 
   MYJOBID=${MYSTARTUP:13}
   MYJOBID=${MYJOBID% -bg}
   echo "Job $MYJOBID"

   while read LINE; do export $LINE; done < 
/var/spool/sge/${HOSTNAME%%.*}/active_jobs/$MYJOBID.1/environment
   unset HISTFILE

   if [ -n "$MYJOBID" ]; then
  . /usr/sge/default/common/settings.sh
   qstat -j $MYJOBID | sed -n -e "/^context/s/^context: *//p" | tr "," "\n" 
| sed -n -e "s/^MESSAGE=//p"
   fi
fi

___
users mailing list
users@gridengine.org
https://gridengine.org/mailman/listinfo/users


[gridengine users] Fwd: Request: JOB_ID, QUEUE, etc. variables in a QLOGIN session

2018-12-12 Thread Gowtham
Greetings.

I am wondering if there's a way to access JOB_ID, QUEUE and other such SGE
variables from within a QLOGIN session. For example,

   1. I type 'qlogin' and gain access to one of the compute nodes.
   2. Running 'qstat -u ${USER}' lists this QLOGIN session with a 'job-ID'
   3. The command, echo ${JOB_ID}, returns blank from within that QLOGIN
   session instead of showing the number displayed in #2.

Please let me know if there's a way to achieve this.

Best regards,
Gowtham

--
Gowtham, PhD
Director of Research Computing, IT
Research Associate Professor, ECE
Michigan Technological University

P: (906) 487-4096
F: (906) 487-2787
https://it.mtu.edu
https://hpc.mtu.edu
___
users mailing list
users@gridengine.org
https://gridengine.org/mailman/listinfo/users