火箭军的专栏

默默学习,天天向上!

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

以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


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huojingjia/article/details/52884368
个人分类: linux相关
想对作者说点什么? 我来说一句

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

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭