Linux下Tomcat启动/停止/重启脚本 来替代Tomcat自身的启动/停止
------------------------脚本开始--------------------------------------------
#!/bin/bash
#This script for tomcat service start/stop/restart/status
#author:leo Email:chanyipiaomiao@163.com date:2011/12/25
TOM_HOME="/usr/local/tomcat6.0.33"
TOM_PATH="${TOM_HOME}/bin"
TOM_STATUS=$( ps -ef | grep -v ''grep'' | egrep "java.*=${TOM_HOME}")
function tomcatstart() {
if [ "${TOM_STATUS}X" == "X" ];then
${TOM_PATH}/startup.sh
START_STATUS=$( ps -ef | grep -v ''grep'' | egrep "java.*=${TOM_HOME}")
while [ "X" = "X" ]
do
if [ "${START_STATUS}" != "" ];then
echo
echo "Tomcat Service Start......................[OK]"
echo
break
fi
START_STATUS=$( ps -ef | grep -v ''grep'' | egrep "java.*=${TOM_HOME}")
done
else
echo
echo "Tomcat Service is Running...."
echo
exit 1
fi
}
function tomcatstop() {
if [ "${TOM_STATUS}X" != "X" ];then
${TOM_PATH}/shutdown.sh
STOP_STATUS=$(ps -ef | grep -v ''grep'' | egrep "java.*=${TOM_HOME}")
while [ "X" == "X" ]
do
if [ "${STOP_STATUS}" == "" ];then
echo
echo "Tomcat Service Stop......................[OK]"
echo
break
fi
STOP_STATUS=$(ps -ef | grep -v ''grep'' | egrep "java.*=${TOM_HOME}")
done
else
echo
echo "Tomcat Service is not Running..."
echo
exit 1
fi
TOM_STATUS=""
}
function tomcatstatus() {
if [ "${TOM_STATUS}X" == "X" ];then
echo
echo "Tomcat Service is not Running..."
echo
exit 1
else
echo
echo "Tomcat Service is Running...."
echo
exit 1
fi
}
function tomcatrestart() {
if [ "${TOM_STATUS}X" == "X" ];then
echo
echo "Tomcat Service is not Running..."
echo
tomcatstart
else
tomcatstop
tomcatstart
fi
}
case $1 in
"start")
tomcatstart
;;
"stop")
tomcatstop
;;
"status")
tomcatstatus
;;
"restart")
tomcatrestart
;;
*)
echo
echo "Usage: $0 start|stop|restart|status"
echo
esac
------------------------脚本结束-------------------------------------------- 本文出自 “雷纳科斯的博客” 博客,请务必保留此出处http://75280.blog.51cto.com/65280/750813
|