Springboot starts, closes, and restarts scripts in Linux as jar packages
Start the
Write the startup script startup.sh
#!/bin/bash echo Starting application
/ etc/profile
nohup java -jar test.jar &
authorization
chmod +x startup.sh
Shut down
Write the close script stop.sh
#!/bin/bash PID=$(ps -ef | grep test.jar | grep -v grep | awk '{ print $2 }') if [ -z "$PID" ] then echo Application is already stopped else echo kill $PID kill $PID fi
authorization
chmod +x stop.sh
restart
Write the restart script restart. Sh
#!/bin/bash echo Stopping application source ./stop.sh echo Starting application source ./startup.sh
authorization
chmod +x restart.sh