启动脚本:亲测可行
#!/bin/sh
APPDIR=`pwd`
PIDFILE=$APPDIR/demo-0.0.1-SNAPSHOT.pid
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
echo "demo is already running..."
exit 1
fi
nohup java -jar demo-0.0.1-SNAPSHOT.jar --spring.config.location=/home/test/config/application.yml,/home/test/config/application-druid.yml,logback.yml,mybatis-config.xml
echo $! > $PIDFILE
echo "start demo success..."
停止脚本:未测试
#!/bin/sh
APPDIR=`pwd`
PIDFILE=$APPDIR/demo-0.0.1-SNAPSHOT.pid
if [ ! -f "$PIDFILE" ] || ! kill -0 "$(cat "$PIDFILE")"; then
echo "demo not running..."
else
echo "stopping demo..."
PID="$(cat "$PIDFILE")"
kill -9 $PID
rm "$PIDFILE"
echo "...demo"
fi