Date Created: Thu 07-Feb-2008

Related Document Categories:



    Kill all WebSphere process in Unix


    listprocess.sh

    #!/bin/ksh
    # Korn Shell Functions file
    #
    # Author: Steve Robinson
    # Date Created: November 2007
    # Arguments: subfolder for environment
    # Description: This script lists all the was process to make it easy to kill all WebSphere servers using Unix
    # Version: 1.0
    # 07-
    #############################################################################################################
    ###################################################################################
    ## Global Variables
    ###################################################################################
    _DEBUG="on"
    ###################################################################################
    ## Debug Function
    ###################################################################################
    DEBUG()
    {
    [ "$_DEBUG" == "on" ] && $@ || :
    }

    Script=`basename $0|awk ' BEGIN { FS="."} { print $1 } '`
    DEBUG echo "$(date +"%x %r %Z"): There are $# arguments to $0: $*"

    ENVIRONMENT=inst50
    ENVPATH=/E50/was/$ENVIRONMENT
    if [ -d $ENVPATH ]; then
    total=`ps -ef | sed 's/^ //g'| grep /E50/was/inst50 |tr -s " "| cut -d " " -f2`
    #echo "total="$total
    echo ""
    for i in $total
    do
    val=`pargs $i 2>/dev/null|cut -d":" -f2-10|grep -i [a-z0-9]|tail -1`
    pid=`echo PID [$i]`
    server=`echo SERVER [$val ]`
    FORMAT="%-8s%-10s%-10s%-12s\n"

    if [[ $val != "" ]] ; then
    ##echo $pid $server
    printf $FORMAT PID $i SERVER $val
    fi
    done

    #Checking environment variables
    if [ "$1" ]
    then
    if [ "$1" = "-k" ]
    then
    DEBUG echo "killing pids: $total"
    `kill $total`
    fi
    fi


    else
    echo "ERROR: no environment is available under $ENVPATH"
    fi
    echo ""

Middleware Mentor - Steven Charles Robinson

About Me

Steve Robinson has been working in IT for over 15 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware consulting. Steve comes from both an administration and development background.

Before moving to JEE, Steve was an accomplished developer and consultant for both IBM Lotus Notes and Microsoft .NET Technologies.

Follow Steve as @stevencrobinson on twitter.

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

Oracle WebLogic Categories

JBoss Categories

Other Categories