jar包部署shell

#!/bin/bash
IFS_old=$IFS
IFS=$'\n'
JAR_NAME=server.jar
LOG_FILE=log.txt
JAVA_OPTS="-server -Xms200m -Xmx200m"

#shut jar use kill
for line in $(ps -ef|grep "$JAR_NAME")
do
	if [[ $line == *-jar* ]];then
		ins_pid=$(echo $line|awk '{print $2}')
		kill -9 $ins_pid
		echo "========$JAR_NAME shutdown it's pid is $ins_pid"========
	fi
done

#start jar
eval "nohup java $JAVA_OPTS -jar $JAR_NAME  >> "$LOG_FILE" 2>&1 &"
echo "========$JAR_NAME startup success and logfile in $(pwd)/$LOG_FILE"========

IFS=$IFS_old

 

你可能感兴趣的:(jar包部署shell)