springboot-Linux shell command to start,stop(kill) or restart springboot executable jar applications
1. The purpose of this post
Sometimes, we package the springboot applications as one single executable jar file and deploy it to the server. We start the jar as follows:
But when we want to stop it or restart it, we need to do follows:
This work is a bit cumbersome,today, I would demo the linux shell commands to kill or restart springboot executable jar applications, you can use one-command to kill or restart the app.
2. Environments
- SpringBoot 1.x or 2.x
3. The commands
3.1 Kill the SpringBoot App
If your springboot jar file name is myapp-exec.jar, kill it as this:
Save the above script as stop.sh
3.2 Start the SpringBoot App in background
To start the app in background, you can use the nohup commmand:
Save the above script as start.sh
3.2 Restart the SpringBoot App
Now you can open an editor to create a file named restart.sh to do the restart job:
Save the above script as restart.sh