标签:grep -v 技术分享 The name jenkins 自动 kill source res
#!/bin/sh
cd /work/his
DATE=`date ‘+%Y%m%d-%H%M‘`
file="$DATE.main-1.0.jar"
cp /work/main-1.0.jar /work/his/$file
RESOURCE_NAME=main-1.0.jar
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk ‘{print $2}‘`
if [ ${tpid} ]; then
echo ‘Stop Process...‘
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk ‘{print $2}‘`
if [ ${tpid} ]; then
echo ‘Kill Process!‘
kill -9 $tpid
else
echo ‘Stop Success!‘
fi
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk ‘{print $2}‘`
if [ ${tpid} ]; then
echo ‘App is running.‘
else
echo ‘App is NOT running.‘
fi
rm -f tpid
source /etc/profile
nohup java -jar ./$RESOURCE_NAME
echo $! > tpid
echo Start Success!
标签:grep -v 技术分享 The name jenkins 自动 kill source res
原文地址:https://www.cnblogs.com/chenlianyong19890418/p/10283594.html