linux环境下编写shell脚本启动和关闭jar包服务程序

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huojingjia/article/details/52884368

以decision-center-0.0.1-SNAPSHOT.jar 为例子:



1. 文件名: start.sh

内容:


#!/bin/sh
export JAVA_HOME=/home/trsadmin/jdk1.7.0_05
export PATH=$JAVA_HOME/bin:$PATH


APPDIR=`pwd`
PIDFILE=$APPDIR/decision-center.pid
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
echo "decision-center is already running..."
exit 1
fi
nohup java -jar decision-center-0.0.1-SNAPSHOT.jar --spring.profiles.active=test >/dev/null 2>&1 &
echo $! > $PIDFILE
echo "start decision-center success..."




2 文件名: stop.sh
内容:

#!/bin/sh


APPDIR=`pwd`
PIDFILE=$APPDIR/decision-center.pid
if [ ! -f "$PIDFILE" ] || ! kill -0 "$(cat "$PIDFILE")"; then
echo "decision-center not running..."
else
echo "stopping decision-center..."
PID="$(cat "$PIDFILE")"
kill -9 $PID
rm "$PIDFILE"
echo "...decision-center stopped"
fi


展开阅读全文

没有更多推荐了,返回首页