#!/bin/bash

echo "************ KILL xxxx Will  Begin... **************"
#得到对应服务的进程号
str=`ps -ef | grep xxxx-0.0.1-SNAPSHOT.jar | grep -v "grep"|awk '{print $2}'`
kill -9 $str
if [ "$?" -eq 0 ]; then
    echo "killed pid is "$str
    echo "kill success"
else
    echo "kill failed"
fi

nowDate=`date +"%Y-%m-%d"`
#重启服务


nohup java -jar xxx-0.0.1-SNAPSHOT.jar &
#自动删除nohup.out文件


rm -rf nohup.out
nowstr=`ps -ef | grep xxx-0.0.1-SNAPSHOT.jar | grep -v "grep"|awk '{print $2}'`
#打印出现在新的进程号
echo "now pid is "$nowstr
echo "************ xxx is  Running... **************"