After the Spring boot project is packaged into an executable jar, for ease of management, we can make a script that manages the steps of starting, stopping, and so on. Instructions for use
Assuming that the script is eventually named App.sh, you can do the following:
# Show Application Status
app status
# foreground start app
run
# background start app start
# Close app
stop app
Background to start the application, you should enter a carriage return, back to the terminal and then exit the terminal, if the application may exit the background run full script
#!/bin/bash
If ["$" = "Run"] then
java-jar application-name.jar
else if ["$" = "start"]; then
no Hup Java-jar Application-name.jar &
echo "Application is starting."
else if ["$" = "Stop"]; Then
pid=$ (ps-ef | grep application-name.jar | grep-v grep | awk ' {print $} ')
if [-Z "$PID"]; then
Echo Application is already stopped
else
echo kill $PID
kill $PID
fi
else if ["$" = "status"]; N
pid=$ (ps-ef | grep application-name.jar | grep-v grep | awk ' {print $} ')
if [-Z "$PID"]; then
Echo Application is stopped
else
Echo application is running
echo $PID
fi
fi fi
fi
Application-name for Application name Other instructions app.sh should configure executable permissions script to use Nohup guarantee application to run continuously in the background