码迷,mamicode.com
首页 > 其他好文 > 详细

jenkins自动化脚本配置

时间:2019-01-17 19:52:36      阅读:163      评论:0      收藏:0      [点我收藏+]

标签: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!

 

jenkins自动化脚本配置

标签:grep -v   技术分享   The   name   jenkins   自动   kill   source   res   

原文地址:https://www.cnblogs.com/chenlianyong19890418/p/10283594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!