Skip to content
Advertisement

Stop current running Spring boot in linux

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 ?

Advertisement

Answer

You kind find the PID of the spring process and send a SIGTERM signal to it.

Find the PID (Here the PID is 12345)

$ ps -ef | grep sssup | awk '{print $2}'
12345

Send a kill signal (This will send the signal SIGTERM)

kill 12345

If the application handles the SIGTERM gracefully, you can force kill it by sending SIGKILL

kill -s SIGKILL 12345
### or
kill -9 12345

Signals are documented here https://www.man7.org/linux/man-pages/man7/signal.7.html

You can list signals and their numbers by running

kill -l

EDIT: Onliner

ps -ef | grep "sssup-SNAPSHO[T]" | awk '{print $2}' | xargs kill
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement