jenkins自动化脚本配置

 

 

 

 

#!/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!

 

posted on 2019-01-17 17:51  cly雪狼  阅读(221)  评论(0编辑  收藏  举报

导航