linux下tomcat部署、启动、关闭的shell脚本
一、直接在tomcat的bin目录下创建脚本
1.部署war包脚本deploy.sh:
#!/bin/sh
war=$1
bin=$(cd `dirname $0`; pwd)
if [ ! -n "${war}" ]; then
echo "***Usage: $0 [project.war]"
exit 0
fi
if [ ! -f "${war}" ]; then
echo "***Error: ${war} does not exist."
exit 0
fi
if [ ! "${war##*.}" = "war" ]; then
echo "***Error: ${war} is not a war file."
exit 0
fi
echo "Deploy ${war##*/}..."
rm -rf ${bin}/../webapps/ROOT/ && unzip -qo ${war} -d ${bin}/../webapps/ROOT/
rm -rf ${bin}/../work/Catalina/localhost/
echo "Restart tomcat..."
exec ${bin}/restart.sh
2.重启脚本 restart.sh :
#!/bin/sh
bin=$(cd `dirname $0`; pwd)
pid=$(ps aux | grep tomcat | grep -v grep | grep -v restart | grep ${bin} | awk '{print $2}')
if [ -n "${pid}" ]; then
echo "Shutdown..."
sh ${bin}/shutdown.sh
sleep 3
pid=$(ps aux | grep tomcat | grep -v grep | grep -v restart | grep ${bin} | awk '{print $2}')
if [ -n "${pid}" ]; then
kill -9 ${pid}
sleep 1
fi
fi
echo "Startup..."
sh ${bin}/startup.sh
if [ "$1" = "-v" ]; then
tail -f ${bin}/../logs/catalina.out
fi
二、部署脚本单独存放
例如:把部署脚本放在 /opt/tomBin 目录下
重启脚本的bin只需固定路径即可,例如:bin="/usr/local/tomcat-8.5/bin"
阅读更多- 在linux中安装jdk以及tomcat并shell脚本关闭启动的进程
- 使用shell脚本 启动关闭tomcat服务
- linux环境下编写shell脚本启动和关闭jar包服务程序
- shell脚本部署并启动tomcat(简单例子)
- Linux环境下WEB应用启动或关闭tomcat脚本编写(二)
- linux使用shell脚本管理其他服务器Tomcat启动停止、自动发布
- shell脚本--部署应用到tomcat并启动tomcat
- 使用shell脚本 启动关闭tomcat服务
- Shell脚本控制tomcat的docker容器的创建,删除,启动,关闭
- Linux 启动停止SpringBoot jar 程序部署Shell 脚本
- [原]Linux环境-Jenkins实战-分布式构建-自动化持续集成-自动化部署-gitlab-svn-shell启动tomcat
- Linux之shell脚本系列 ----- 服务启动/关闭/重启/状态
- shell 脚本解压war包+备份+tomcat自动关闭+启动
- linux环境下编写shell脚本实现启动停止tomcat服务的方法
- Linux中对Tomcat的启动,部署,关闭,查看日志操作(最常用命令)
- shell脚本启动,关闭tomcat
- shell脚本--部署应用到tomcat并启动tomcat
- linux环境在tomcat启动或者停止后执行shell脚本,脚本内容备份图片文件夹
- 关闭tomcat, 部署并启动tomcat的脚本
- Linux命令启动关闭tomcat部署的项目