NAME="demo-0.0.1-SNAPSHOT.jar" #想要杀死的进程
ID=`ps -ef | grep "$NAME" | grep -v "grep" | awk '{print $2}'`
if [ -z "$ID" ];then
echo "process id is empty, process is not existed..."
nohup java -jar /home/output/demo-0.0.1-SNAPSHOT.jar > /home/output/$jarname-log.log 2>&1 &
echo "process has start..."
else
echo $ID
for id in $ID
do
kill -9 $id
echo "killed $id"
done
nohup java -jar /home/output/demo-0.0.1-SNAPSHOT.jar > /home/output/$jarname-log.log 2>&1 &
echo "process has restart..."
fi