#!/bin/test_restart.sh #Author : Javen
#Desc : restart tomcat-test tomcatpath="/home/local/testJaven/tomcat-test"
tomcatname="tomcat-test" if [ $# -ne ]; then
ps -ef | grep java | grep ${tomcatpath};
pid=$(ps -ef | grep java | grep ${tomcatpath} | awk '{print $2}')
else
pid=$
fi echo -e "Before start ${tomcatpath}, should kill the same run, kill pid ${pid}, and will start new ${tomcatname} \c"
kill - $pid
sleep
cd ${tomcatpath}/bin
./startup.sh
tomcatpath 为tomcat在服务器完整的路径
tomcatname 为tomcat目录的名称

如果执行提示没有权限 添加一下执行权限 chmod +x test_restart.sh

05-27 05:55