Tomcat启动脚本

回复 收藏
-bash-4.1# cat tomcat.sh
#!/bin/bash
#date  2016-06-17
#Author ouyang
#

usage () {
    echo -e "\033[35mUsage: $0 [start|stop|status|restart]\033[0m"

}
tomcat_start () {
    /usr/local/tomcat/bin/startup.sh
}

tomcat_status () {
STAT=$(ps aux |grep java|grep tomcat|grep -v 'grep'|awk '{print $2}')
    if [ ! -z $STAT ];then
        echo -e "\033[32mTomcat is Running...\033[0m"
    else
        echo -e "\033[33mTomcat is not Running...\033[0m"
    fi

}

tomcat_stop () {
TOM_PATH=/usr/local/tomcat
TPID=$(ps aux |grep java|grep tomcat|grep -v 'grep'|awk '{print $2}')
kill -9 $TPID
sleep 5;

TSTAT=$(ps aux |grep java|grep tomcat|grep -v 'grep'|awk '{print $2}')
    if [ -z $TSTAT ];then
        echo -e "\033[32mtomcat stop success...\033[0m"
    else
        kill -9 $TSTAT
    fi

rm -rf $TOM_PATH/temp/*
rm -rf $TOM_PATH/work/*
}

main () {
case $1 in
    start)
        tomcat_start;;
    stop)
        tomcat_stop;;
    status)
        tomcat_status;;
    restart)
        tomcat_stop && tomcat_start;;
    *)
        usage;
esac
}

main $1


执行脚本测试:
111.png





2016-06-17 13:56 举报
已邀请:
0

津蛇康健

赞同来自:

echo -e "\033[35mUsage: $0 [start|stop|status|restart]\033[0m"

这里面的 \033[35mUsage:   和 \033[0m  是什么意思啊?

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: