linux重启tomcat 小脚本
#!/bin/sh
#definition path
shutdownPath=/home/control/local/tomcat12006/bin/shutdown.sh
startupPath=/home/control/local/tomcat12006/bin/startup.sh
cachePath=/home/control/local/tomcat12006/work
#pid
tomcatId=$(ps aux|grep tomcat12006|grep -v 'grep'|awk '{print $2}')
if [ -n "$tomcatId" ];then
echo "当前tomcat进程ID为:$tomcatId,准备关闭后重新启动。"
kill -9 $tomcatId
sleep 3
echo '清理tomcat缓存'
rm -rf $tomcatCache
sleep 3
echo '准备启动tomcat'
$startupPath
else
echo "tomcat没有启动,开始重启..."
echo '清理tomcat缓存'
rm -rf $tomcatCache
sleep 3
echo '准备启动tomcat'
$startupPath
fi
echo "----------执行完毕--------------------"