tomcat停止和启动脚本
日常重启tomcat比较麻烦,所以写了2个脚本,在脚本后输入tomcat名称即可
启动或重启tomcat
#!/bin/sh
TOMCAT_HOME=/usr/java/$1
if [ ! -n "$1" ]; then
echo "请输入tomcat名称!!!"
elif [ ! -d "${TOMCAT_HOME}" ]; then
echo "目录不存在!!!"
else
echo "===============================${TOMCAT_HOME}=========================="
pid=$(ps -ef|grep ${TOMCAT_HOME} |grep -v 'grep'|awk '{print $2}')
if [ ! -n "${pid}" ]; then
echo "==========================start tomcat========================"
else
for temp_pid in ${pid}
do
echo "=========================restart tomcat======================"
echo ${temp_pid}
kill -9 ${temp_pid}
done
fi
${TOMCAT_HOME}/bin/startup.sh
fi
停止tomcat
#!/bin/sh
TOMCAT_HOME=/usr/java/$1
if [ ! -n "$1" ]; then
echo "请输入要停止的tomcat名称!!!"
elif [ ! -d "${TOMCAT_HOME}" ]; then
echo "目录不存在!!!"
else
echo "=====================${TOMCAT_HOME}============================"
pid=$(ps -ef|grep ${TOMCAT_HOME} |grep -v 'grep'|awk '{print $2}')
if [ ! -n ${pid} ]; then
echo "could not find pid"
else
for temp_pid in ${pid}
do
echo ${temp_pid}
kill -9 ${temp_pid}
done
fi
fi