#!/bin/bash
process_name="org.apache.catalina.startup.Bootstrap"
shutdown_call=
function shutdownTomcat() {
process_pid=`ps -ef | grep "$process_name" | grep -v "grep" | awk '{ print $2 }'`
for i in $process_pid
do
echo "INFO: Kill the tomcat process [ $i ]"
kill - $i
done
shutdown_call=
}
function getProcessNum() {
process_num=`ps -ef | grep "$process_name" | grep -v "grep" | wc -l`
return $process_num
}
function checkYnAgain() {
while true; do
read -p "Please type \"Y\" or \"N\". " yn
case $yn in
[Yy]|[Yy][Ee][Ss] )
shutdownTomcat
break;;
[Nn]|[Nn][Oo] )
echo "exiting..."
exit;;
esac
done
}
getProcessNum
tomcat_process_num=$?
if [ $tomcat_process_num -gt ]; then
echo "INFO: Tomcat server is running..."
read -p "Do you want to shutdown tomcat server now [Y/N]? " yn
case $yn in
[Yy]|[Yy][Ee][Ss] )
shutdownTomcat;;
[Nn]|[Nn][Oo] )
echo "exiting..."
exit;;
* )
checkYnAgain;;
esac
fi
getProcessNum
tomcat_process_num=$?
if [ $tomcat_process_num -gt ]; then
echo "ERROR: Fail to shutdown tomcat server."
echo "You have to shutdown tomcat server or kill its process manually."
exit
elif [ $shutdown_call -eq ]; then
echo "INFO: Shutdown tomcat server success."
fi
05-11 13:16