tomcat启动、停止和重启脚本

脚本名称:r.sh

脚本用途:启动、停止和重启tomcat

脚本参数:$1:[start|stop|restart]

 

#!/bin/bash
BIN_PATH="/tomcat_path/bin"
LOG="/tomcat_path/logs/catalina.out"
NAME="app_name"

function start()
{
        cd $BIN_PATH
        rm -rf ../work/*
        ./catalina.sh start
        tail -f $LOG
}

function stop()
{
        PID=`ps -ef | grep $NAME | grep java | awk '{print $2}'`
        for i in $PID
        do
                kill -9 $i
        done
}

function restart()
{
        stop
        start
}

if [ "$#" != "1" ];then
        echo "参数个数不为1"
        exit 1
fi

case $1 in
start)
        start
        ;;
stop)
        stop
        ;;
restart)
        restart
        ;;
*)
        echo "参数错误"
        ;;
esac

 

posted @ 2015-05-13 16:42  大盗—如风  阅读(251)  评论(0编辑  收藏  举报