Date Created: Tue 05-Feb-2008

Related Document Categories:

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/



    kill WebSphere servers with shell script

    The shell script below shows one possible method of how to kill all servers on a node by name. Not a very elegant solution, but very useful. A possible upgrade would be to have a master routine which uses ssh to kill servers on all nodes in the cell. I will post a multi node cell solution when I have it written. My next version will also use a props file for server names to allow the script to be generic.

    This script should also run in bash.

    #!/bin/ksh
    # BASH Functions file
    #
    # OS: Solaris 9
    # Author: Steve Robinson
    # Date Created: February 2008
    # Arguments: none
    # Description: This script used a script to stop all servers as specified in a string.
    # Version: 1.0
    # History:
    #
    ENVIRONMENT=instxx
    ENVPATH=/xxx/was/$ENVIRONMENT
    if [ -d $ENVPATH ]; then
    #total=`ps -ef | sed 's/^ //g'| grep /xxx/was/instxx |tr -s " "| cut -d " " -f2`
    total=`pgrep -f -u wasadmxx '/xxx/was/instxx'`
    echo "total="$total
    echo "my own pid=$$"
    #echo ""
    serverstokill="server01 server02 server03"
    echo "servers to kill=$serverstokill"
    for i in $total
    do
    val=`pargs $i 2>/dev/null|cut -d":" -f2-10|grep -i [a-z0-9]|tail -1`
    FORMAT="%-8s%-10s%-10s%-12s\n"
    if [ $val != "" -a $i != $$ -a $val != "nodeagent" -a $val != "dmgr" ]; then
    printf $FORMAT $i $val
    for s in $serverstokill
    do
    s=`echo $s | sed 's/^[ \t]*//;s/[ \t]*$//'`

    if [ $val = $s ];
    then
    echo "Killing pid[$i] process id of server:[$s]"
    #kill $i
    break
    fi
    done
    fi
    done
    else
    echo "ERROR: no environment is available under $ENVPATH"
    fi
    echo ""

    Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/


Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories