Thursday, May 31, 2012

stopNodeManager.sh


here is a stop script that can be helpful when you have multiple node managers running in a machine

first edit your startNodeManager.sh to give a name for your server by a -D flag, I have it as  TSTNM

JAVA_OPTIONS="-Dbea.home=${BEA_HOME} -DTSTNM  ${JAVA_OPTIONS}"

 next create below ssh file,  location doesn't matter I would put under nodemanager home to avoid confusion. Invoking  ./stopNodeManager.sh   should stop your nm

stopNodeManager.sh


#!/bin/sh
#
function ConfirmOrExit() {
while true
do
echo -n "Please confirm (y or n) :"
read CONFIRM
case $CONFIRM in
y|Y|YES|yes|Yes) break ;;
n|N|no|NO|No)
echo NM stop not attemped since  - you entered $CONFIRM
exit
;;
*) echo Please enter only y or n
esac
done
}
PID=`ps -ef | grep TSTNM | grep -v grep | awk '{print $2}'`
if [ "$PID" == "" ]; then
        echo "TSTNM is inactive!"
else
        echo -e Terminate TSTNM with PID: $PID..
        ConfirmOrExit
        kill -9 $PID
        echo -e Terminated TSTNM with PID: $PID..
fi



No comments:

Post a Comment