JVM Auto Restart Script in WebSphere Application Server
#!/bin/ksh
#host=`hostname`
echo "Enter the JVM you want to restart"
read JVM
#########################kill and start JVM####################
echo "\nStarting restart $JVM process..at `date`"
echo `cat /usr/WebSphere61/AppServer/profiles/AppServer/logs/$JVM/$JVM.pid` | xargs kill -9 ; rm /usr/WebSphere61/AppServer/profiles/AppServer/logs/$JVM/$JVM.pid
sleep 5
if [ -f /usr/WebSphere61/AppServer/profiles/AppServer/logs/$JVM/$JVM.pid ]
then
echo "\n$JVM restarted by nodeagent.."
else
echo "\n$JVM has not been restarted by nodeagent..starting it now.."
echo ""
. /usr/WebSphere61/AppServer/profiles/AppServer/bin/setupCmdLine.sh
/usr/WebSphere61/AppServer/profiles/AppServer/bin/startServer.sh $JVM
fi
#########################check JVM start or not#################
until [ -f /usr/WebSphere61/AppServer/profiles/AppServer/logs/$JVM/$JVM.pid ]
do
sleep 2
echo $JVM not start yet, wait....
done
echo ""
echo $JVM restart successfully
echo "$JVM restarted successfully has been started on server $host. Please check. " | mailx -r "xxx@abc.com" -s "Port Monitoring Alert - $JVM - $host" "xxx@abc.com
$
#!/bin/ksh
#host=`hostname`
echo "Enter the JVM you want to restart"
read JVM
#########################kill and start JVM####################
echo "\nStarting restart $JVM process..at `date`"
echo `cat /usr/WebSphere61/AppServer/profiles/AppServer/logs/$JVM/$JVM.pid` | xargs kill -9 ; rm /usr/WebSphere61/AppServer/profiles/AppServer/logs/$JVM/$JVM.pid
sleep 5
if [ -f /usr/WebSphere61/AppServer/profiles/AppServer/logs/$JVM/$JVM.pid ]
then
echo "\n$JVM restarted by nodeagent.."
else
echo "\n$JVM has not been restarted by nodeagent..starting it now.."
echo ""
. /usr/WebSphere61/AppServer/profiles/AppServer/bin/setupCmdLine.sh
/usr/WebSphere61/AppServer/profiles/AppServer/bin/startServer.sh $JVM
fi
#########################check JVM start or not#################
until [ -f /usr/WebSphere61/AppServer/profiles/AppServer/logs/$JVM/$JVM.pid ]
do
sleep 2
echo $JVM not start yet, wait....
done
echo ""
echo $JVM restart successfully
echo "$JVM restarted successfully has been started on server $host. Please check. " | mailx -r "xxx@abc.com" -s "Port Monitoring Alert - $JVM - $host" "xxx@abc.com
$