#!/bin/test_restart.sh #Author : Javen #Desc : restart tomcat-test tomcatpath="/home/local/testJaven/tomcat-test" tomcatname="tomcat-test" if [ $# -ne 1 ]; then ps -ef | grep java | grep ${tomcatpath}; pid=$(ps -ef | grep java | grep ${tomcatpath} | awk ‘{print $2}‘) else pid=$1 fi echo -e "Before start ${tomcatpath}, should kill the same run, kill pid ${pid}, and will start new ${tomcatname} \c" kill -9 $pid sleep 9 cd ${tomcatpath}/bin ./startup.sh
如果执行提示没有权限 添加一下执行权限 chmod +x test_restart.sh
时间: 2024-10-11 12:26:19