Start / Stop script for springboot app on linux, with following features:

  1. Start script won’t create new instance if the app already running
  2. Run the app in background and forward all console output to “log.log”

1. Start Script


if [ -f "./PID" ]; then
  echo "PID exists, app already running"
  nohup java -jar ./MyApp-0.1-SNAPSHOT.jar > log.log 2>&1 &
  echo $! > PID

2. Stop Script


kill `cat ./PID`
rm PID