{"id":3239,"date":"2014-06-24T00:17:47","date_gmt":"2014-06-23T16:17:47","guid":{"rendered":"http:\/\/rmohan.com\/?p=3239"},"modified":"2014-06-24T00:17:47","modified_gmt":"2014-06-23T16:17:47","slug":"websphere-restart-script","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3239","title":{"rendered":"websphere restart script"},"content":{"rendered":"<p>#!\/bin\/ksh<\/p>\n<p>BASENAME=`basename $0`<\/p>\n<p>WAZZZ_HOME=\/usr\/WebSphere\/AppServer<br \/>\nJVVVM_BIN_DIR=$WAZZZ_HOME\/profiles\/node01\/bin<\/p>\n<p>die_usage()<br \/>\n{<br \/>\necho &#8220;usage: $BASENAME: &lt;jvm name&gt; &lt;timeout&gt; &lt;hard retries&gt;&#8221;<br \/>\nexit $1<br \/>\n}<\/p>\n<p>[[ $# -eq 3 ]] || die_usage 111<\/p>\n<p>JVVVM_NAME=$1<br \/>\nTIMEOUT=$2<br \/>\nHARD_RETRIES=$3<\/p>\n<p>JVVVM_LOG_DIR=$WAZZZ_HOME\/profiles\/node01\/logs\/$JVVVM_NAME<br \/>\nJVVVM_PID=<\/p>\n<p>$JVVVM_BIN_DIR\/serverStatus.sh -all | grep &#8221; $JVVVM_NAME&#8221; | grep -v grep | grep -v $BASENAME &gt; \/dev\/null 2&gt;&amp;1<\/p>\n<p>if [[ $? -ne 0 ]]<br \/>\nthen<br \/>\necho &#8220;usage: $BASENAME: $JVVVM_NAME is not a recognized WAS 6 jvm.&#8221;<br \/>\nexit 111<br \/>\nfi<\/p>\n<p>if [[ -e $JVVVM_LOG_DIR\/${JVVVM_NAME}.pid ]]<br \/>\nthen<br \/>\n# First lets verify that this PID is actually running<br \/>\nPS_PID=$(ps auxwww | grep &#8221; $JVVVM_NAME&#8221; | grep -v grep | grep -v $BASENAME | awk -F&#8221; &#8221; &#8216;{print $2}&#8217; | head -1)<\/p>\n<p># Lets get the PID from the JVVVM&#8217;s pid file<br \/>\nFILE_PID=$(cat $JVVVM_LOG_DIR\/${JVVVM_NAME}.pid)<\/p>\n<p>if [[ $PS_PID -eq $FILE_PID ]]<br \/>\nthen<br \/>\nJVVVM_PID=$FILE_PID<br \/>\nelse<br \/>\nJVVVM_PID=$PS_PID<br \/>\nfi<br \/>\nfi<\/p>\n<p>echo &#8220;INFO: $BASENAME: Stopping the $JVVVM_NAME JVM with process id: $JVVVM_PID&#8221;<br \/>\n# At this point the JVVVM should be running, lets kill it<br \/>\n# This is a timed stop.\u00a0 It will run for the specified<br \/>\n# Timeout value before killing itself in disgust<\/p>\n<p>echo &#8220;INFO: $BASENAME: Attempting graceful stop of $JVVVM_NAME&#8230;&#8221;<br \/>\n$JVVVM_BIN_DIR\/stopServer.sh $JVVVM_NAME &gt; \/dev\/null 2&gt;&amp;1 &amp; {<br \/>\nsleep ${TIMEOUT} &gt; \/dev\/null 2&gt;&amp;1<br \/>\neval &#8216;kill -9 $! &gt; \/dev\/null 2&gt;&amp;1&#8217;<br \/>\n}<\/p>\n<p>#<br \/>\n# Do another quick check to see it is still running<br \/>\n#<br \/>\nps auxwww| grep &#8221; $JVVVM_NAME&#8221; | grep -v grep | grep -v $BASENAME &gt; \/dev\/null 2&gt;&amp;1<br \/>\nIS_RUNNING=$?<\/p>\n<p>if [[ $IS_RUNNING -eq 0 ]]<br \/>\nthen<br \/>\necho &#8220;WARN: $BASENAME: Graceful stop failed.\u00a0 Entering hard kill loop&#8230;&#8221;<br \/>\nCOUNT=1<br \/>\nwhile ((COUNT &lt; HARD_RETRIES))<br \/>\ndo<br \/>\nPIDID=$(ps auxwww | grep &#8221; $JVVVM_NAME&#8221; | grep -v grep | grep -v $BASENAME | awk -F&#8221; &#8221; &#8216;{print $2}&#8217; | head -1)<br \/>\necho &#8220;INFO: $BASENAME: Trying to hard stop the JVM process: ${PIDID} Count: ${COUNT}&#8230;&#8221;<br \/>\nkill -9 ${PIDID}<br \/>\n((COUNT = COUNT + 1))<br \/>\nsleep 7<br \/>\ndone<br \/>\nfi<\/p>\n<p>echo &#8220;INFO: $BASENAME: $JVVVM_NAME has been stopped.&#8221;<\/p>\n<p>exit 0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/ksh<\/p>\n<p>BASENAME=`basename $0`<\/p>\n<p>WAZZZ_HOME=\/usr\/WebSphere\/AppServer JVVVM_BIN_DIR=$WAZZZ_HOME\/profiles\/node01\/bin<\/p>\n<p>die_usage() { echo &#8220;usage: $BASENAME: &lt;jvm name&gt; &lt;timeout&gt; &lt;hard retries&gt;&#8221; exit $1 }<\/p>\n<p>[[ $# -eq 3 ]] || die_usage 111<\/p>\n<p>JVVVM_NAME=$1 TIMEOUT=$2 HARD_RETRIES=$3<\/p>\n<p>JVVVM_LOG_DIR=$WAZZZ_HOME\/profiles\/node01\/logs\/$JVVVM_NAME JVVVM_PID=<\/p>\n<p>$JVVVM_BIN_DIR\/serverStatus.sh -all | grep &#8221; $JVVVM_NAME&#8221; | grep -v grep | grep -v $BASENAME &gt; \/dev\/null 2&gt;&amp;1<\/p>\n<p>if [[ $? -ne 0 ]] then [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3239"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3239"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3239\/revisions"}],"predecessor-version":[{"id":3241,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3239\/revisions\/3241"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}