Tomcat自动化脚本

发布时间 2023-12-26 09:45:44作者: Kwoky

/bin/bash

war包名称

war_name="tchg.war"

要上传war包指定目录

war_dir="/usr/local/src/tchg"

工程地址

code_dir="/Lims/tchg/apache-tomcat-9.0.48/webapps/tchg"

tomcat地址

tomcat_dir="/Lims/tchg/apache-tomcat-9.0.48"

工程war地址

war_webapps="/Lims/tchg/apache-tomcat-9.0.48/webapps/"

kill tomcat进程

tomcat_pid=$(ps -ef |grep tomcat | grep -w /Lims/tchg/apache-tomcat-9.0.48/bin | grep -v 'grep' | awk '{print $2}')
kill -9 $tomcat_pid
if [ $? -ne 0 ];then
echo -e "\033[31m\033[01m [ old tomcat kill failed ]\033[0m"
else
echo -e "\033[32m[ kill old tomcat success with pid: $tomcat_pid ]\033[0m"
fi

删除 工程下的war包跟工程目录

rm -rf $code_dir
rm -rf $war_name
echo "delete last $war_name project files $code_dir"
cp -rf $war_dir/*.war $war_webapps

重启tomcat

cd $tomcat_dir/bin
sh startup.sh