i am running a springboot application in linux.To run this springboot we use below command.
java -jar sssup-SNAPSHOT.jar &
This spring boot application makes an endpoint available which is then used by other services.
Now when the new version of .jar is available i have to stop the current running .jar and again run the above mentioned command.
Here my question is how to stop the current running sssup-SNAPSHOT.jar ?
Since you are running the process in the background you need to find its process first to kill it.
To find the process ID fire below command:
ps -ef | grep "sssup-SNAPSHOT.jar"
The output will look something like below:
502 5980 5964 0 10:40AM ttys000
Your second column is your process ID So, over here it is 5980. After copying that fire below command.
kill 5980
Just check again by firing ps -ef command that it gets killed or not. If it's not killed already than you can use -9 flag to force kill it. Like kill -9 <PID>
One way is to bring the background process to the foreground with the fg command and then press Ctrl+C. This will only work if you are in the same terminal where you ran the JAR file.
Another more reliable way is to use ps -a | grep java to find the process id of your app. Then you can do kill <PID> with that process id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With