Start / Stop script for springboot app on linux, with following features:
- Start script won’t create new instance if the app already running
- Run the app in background and forward all console output to “log.log”
1. Start Script
#!/bin/bash
if [ -f "./PID" ]; then
echo "PID exists, app already running"
else
nohup java -jar ./MyApp-0.1-SNAPSHOT.jar > log.log 2>&1 &
echo $! > PID
fi
2. Stop Script
#!/bin/bash
kill `cat ./PID`
rm PID