tomcat 重启
#!/bin/bash
#需要重启的tomcat路径
tomcats=("/opt/tomcat/apache-tomcat8080" "/opt/tomcat/apache-tomcat8081")
#关闭tomcat
for tocmat in ${tomcats[@]}
do
pid=`ps -ef | grep java | grep -w $tocmat | awk '{print $2}'`
echo -e "$tocmat"——"$pid"
kill -9 $pid
done
#启动tomcat
for tocmat in ${tomcats[@]}
do
bash "$tocmat"/bin/startup.sh
pid=`ps -ef | grep java | grep -w $tocmat | awk '{print $2}'`
echo -e "$tocmat"——"$pid"
done
springboot重启
#!/bin/bash
#服务名称
RESOURCE_NAME=springboot.jar
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!' ${tpid}
kill -9 $tpid
else
echo 'Stop Success !' ${tpid}
fi
nohup java -jar $RESOURCE_NAME --spring.profiles.active=product>/dev/null 2>&1 &
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
echo Start Success ${tpid}!
网友评论