Linux下Tomcat启动/停止/重启脚本
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......................"
[*] 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......................"
[*] 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
页:
[1]