Wednesday, June 8, 2016

Weblogic 12c: start and stop script for nodemanager

Recently I was working on the automated script to start and stop the nodemanager, AdminServer and all managed server (ESS, SOA, OSB, WSM) in a domain. So in this post I am going to share my work, it may be possible that these scripts may not be suited for your environment but yes It must give you a basic idea of how to start and stop nodemanager automatically.

Start scripts for nodemanager

Well the basic logic that I used to start the nodemanager is

  • check if nodemanager is running or not
  • start the nodemanager and take the output in a temporary file.
  • while the nodemanager is starting keep looking for the string "socket listener started on port" in a temporary file. 
  • if the matching string is found that means node manager is started and exit().
rm -rf nodemanage.*

status= ps -eaf | grep "weblogic.NodeManager" | grep -v grep| wc -l
echo $status
echo "Node Manager Directory: " $1

if [[ "$status" -eq 0 ]]; then
echo  $date " :Starting Weblogic NodeManager..."
echo $1
nohup $1 > $tfile 2>&1 &

echo  $date " :NodeManager is already RUNNING.."

if [ "$?" != 0 ]; then
echo "Command Failed To Execute Properly"
exit 1;

export a=0;
while [ $a -lt 10 ]; do
echo $tfile

count=$(cat $tfile | grep "socket listener started on port" | wc -l)

echo "The value of count is ${count}"                 

if [[ "$count" -gt 0 ]]; then
echo "NodeManager Started..."
rm -f $tfile
exit 0
echo "Waiting For NodeManager To Start..."
echo $a
sleep 5s
echo "Please check ${tfile} log file for more issues"
exit 1

Save the above script in .sh file e.g. Now to run this script you have to pass the location of the nodemanager i.e.

nohup ./ $DOMAIN_HOME/bin/ > nodemanage.out &

Stop script for nodemanager

To stop the nodemanager find the process id of nodemanager instance and kill that process id, here is the script below:

node1=$(ps -ef | grep weblogic.nodemanager | grep config=/u01 | awk '{printf $2}')

kill -9 $node1

Save the above code in the .sh file e.g. and execute the script as below:

nohup sh &

In the next post I am going to share the start and stop script for weblogic AdminServer and Managed server.

No comments:

Post a Comment