解决Linux下多次重启tomcat进程无法杀干净
2017-11-02 本文已影响0人
Coder95
一共两个shell文件,shutdown-force.sh和restart.sh。均可单独使用,放到tomcat的bin目录下即可,要赋予777权限
shutdown-force.sh
path=$(cd "$(dirname "$0")"; pwd)
ps -ef|grep $path|grep java|awk '{print $2}'
echo "exec $path/shutdown.sh"
$path/shutdown.sh
sleep 3s
#kill -9 pid
ps -ef|grep $path|grep java|awk '{print $2}'|xargs kill -9
#success msg
echo "shutdown success"
ps -ef|grep $path|grep java|awk '{print $2}'
restart.sh
set fileformat=unix
#!/bin/bash
path=$(cd "$(dirname "$0")"; pwd)
echo "exec $path/shutdown-force.sh"
$path/shutdown-force.sh
sleep 3s
$path/startup.sh
echo "restart success"