编写bash脚本快速kill或启动tomcat

​假设tomcat安装路径为 /home/tomcat,示例如下:

1. kill tomcat进程

vim kill-tomcat-force.sh

set fileformat=unix
path=/home/tomcat/bin

echo"exec $path/shutdown.sh"
$path/shutdown.sh

sleep3s

#kill -9 pid
ps -ef|grep $path|grep tomcat|awk '{print $2}'|xargs kill-9

#success msg
echo "shutdown success"

2. start tomcat

vim startTomcat.sh

echo 'start tomcat'
/home/tomcat/bin/startup.sh 
sleep 3s

3. 查tomcat日志

vim showLog.sh

tail -f /home/tomcat/logs/catalina.out
posted @ 2024-11-27 10:07  李济宏(Amadeus)  阅读(8)  评论(0编辑  收藏  举报