jenkins构建后启动jar包
#!/bin/bash
source /etc/profile
set -x
echo -e "\n\n\n"
pids=`ps -ef | grep 'java -Dfile.encoding=utf-8 -jar /home/gaussDB/ui2.0/icp-app-1.0-SNAPSHOT.jar' |grep -v 'grep'|grep -v 'restartApp.sh' |awk '{print $2}'`
count=0
pid_num=0
for pid in ${pids}
do
pid_num=${pid}
echo "pid_num:${pid_num}"
#count=`expr ${count}+1`
count=$(($count+1))
echo "count: ${count}"
done
if [[ $count -gt 1 ]]
then
echo "一个项目有两个进程 异常"
else
kill -9 ${pids}
echo "Kill ${pids} Success!"
rm -rf /opt/icp-app-1.0-SNAPSHOT.jar
#cp /home/linshi/icp-app-1.0-SNAPSHOT.jar /opt/icp-app-1.0-SNAPSHOT.jar
#重启
echo "重启中。。。。。。。"
# BUILD_ID=DONTKILLME
nohup java -Dfile.encoding=utf-8 -jar /home/gaussDB/ui2.0/icp-app-1.0-SNAPSHOT.jar >/dev/null 2>&1 &
fi
echo -e "\n\n\n"

浙公网安备 33010602011771号