引用步聚
引用1. 下载tomcat,解压安装
引用2.将tomcat下的webapps,conf,temp等目录分别拷至根目录www下A,B,C目录下
引用3.新建如下
脚本restart_tomcat.sh
引用4.使用restart_tomcat.sh A/B/C
class="java" name="code">
#!/bin/sh
if [ -z $1 ]
then
echo -e "\033[31;1mplease input the app which you need restart...\033[0m"
exit 1
fi
base_dir=/disk/www
CATALINA_HOME=$TOMCAT_HOME
if [ ! -d ${base_dir}/$1 ]; then
echo -e "\033[31;1mcan't find the directory [${base_dir}/$1] or the [${base_dir}/$1] is no a directory, please check it...\033[0m"
exit 1
fi
if [ ! -f ${base_dir}/$1/conf/server.xml ]; then
echo -e "\033[31;1mcan't find the file [${base_dir}/$1/conf/server.xml] or the [${base_dir}/$1/conf/server.xml] is not a file, please check it...\033[0m"
exit 1
fi
if [ ! -d ${base_dir}/$1/webapps ]; then
echo -e "\033[31;1mcan't find the directory [${base_dir}/$1/webapps] or the [${base_dir}/$1/webapps] is not a directory, please check it...\033[0m"
exit 1
fi
res=`ps aux | grep $1|grep "$JAVA_HOME/bin/java"|egrep -v "grep"|awk '{print $2}'`
if [ -z $res ]; then
echo -e "\033[44;38;1mthe tomcat is not running, begin startup...\033[0m"
else
echo -e '\033[45;35;1mcurrent running pid is' $res'...\033[0m'
#ps aux | grep $1 | grep -v 'grep' &&
${CATALINA_HOME}/bin/shutdown.sh -config ${base_dir}/$1/conf/server.xml
if [ $? -eq 0 ]; then
echo -e "\033[44;38;1mtomcat shutdown successfully...\033[0m"
else
kill -9 `ps aux | grep $1 | grep -v grep | awk '{print $2}'` && echo -e "\033[44;38;1mtomcat killed sucess ..\033[0m"
fi
fi
CATALINA_BASE=${base_dir}/$1
export CATALINA_BASE
if [ -f ${CATALINA}/setenv.sh ];then
. "${CATALINA_BASE}/setenv.sh"
echo "================="
else
echo "+++++++++++++++++++==="
fi
${CATALINA_HOME}/bin/startup.sh -config ${base_dir}/$1/conf/server.xml && echo -e "\033[44;32;1mTomcat startup finished...\033[0m"
pid=`ps aux | grep $1|grep "$JAVA_HOME/bin/java"|egrep -v "grep"|awk '{print $2}'`
echo -e "\033[46;38;1mrunning pid is ${pid}...\033[0m"