Linux 重启Tomcat脚本

#!/bin/test_restart.sh #Author : Javen
#Desc : restart tomcat-test
 
tomcatpath="/home/local/testJaven/tomcat-test"
tomcatname="tomcat-test"
 
 
if [ $# -ne 1 ]; then
        ps -ef | grep java | grep ${tomcatpath};
        pid=$(ps -ef | grep java | grep ${tomcatpath} | awk '{print $2}')
else
        pid=$1
fi
 
echo -e "Before start ${tomcatpath}, should kill the same run, kill pid ${pid}, and will start new ${tomcatname}  c"
kill -9 $pid
sleep 9
cd ${tomcatpath}/bin
./startup.sh
tomcatpath 为tomcat在服务器完整的路径
tomcatname 为tomcat目录的名称


如果执行提示没有权限 添加一下执行权限 chmod +x test_restart.sh 

原文地址:https://www.cnblogs.com/zyw-205520/p/5432158.html