Unix-List all instances of weblogic instances running on a server
At times we need to find the weblogic instances which are up and running on a particular machine mostly in clustered environments. This might be required to figure out weblogic process from a particular domain and kill that process.
You can do a grep as below which gives all the Java processes running on the machine and it may be tough to correlate PID with the running server instances.
$ps -ef | grep java 
Below shell script can be handy to list down the servers running on a particular machine.
clear
echo "PID and  webLogic instances"
echo  "**************************************"
/usr/ucb/ps -awwx | grep "weblogic.Name" | grep -v "grep weblogic.Name" | nawk 'BEGIN {print "PID\tWeblogicServer";
print  "**************************************" } ;
        {
        NUM = match($0, "weblogic.Name=") ;
        START_POS  = RSTART+RLENGTH ;
        START_STR = substr($0, START_POS) ;
        FINISH = match(START_STR, " ") ;
        FINISH_POS = START_POS+RSTART+RLENGTH ;
        FINISH_STR = substr($0, START_POS, FINISH_POS) ;
        NUM = split(FINISH_STR,FINISH_ARRAY) ;
        printf ("%s\t%s\n",$1, FINISH_ARRAY[1]) ;
        }
        END {
        print "**********************************"}'
Below is a sample output.
PID and  webLogic instances
**************************************************
PID     WeblogicServer
**************************************************
12624   AdminServer
13367   wls_soa1
13369   wls_wsm1
**************************************************
To stop a particular server issue the below.
$ kill -9 PID
If it's admin server,to avoid the conflict of existing .lok and .DAT files you can remove the tmp and cache folders or rename them.
 
 
Useful script..
ReplyDelete