Java Zero to All All questionsPractise free
Interview questions › Linux, Networking & Observability › Linux Essentials & Shell

What's the difference between kill -15 and kill -9 for a Spring Boot app, and why prefer one?

Level II · JuniorLinux Essentials & Shell
Answer

kill -15 sends SIGTERM, which the JVM catches so shutdown hooks run: Spring Boot stops accepting new requests, drains in-flight ones if graceful shutdown is enabled, and closes DB connections and flushes buffers cleanly. kill -9 is SIGKILL, which the kernel applies immediately with no chance for the JVM to react, risking half-finished transactions, leaked connections, and unflushed writes. Always try -15 first with a timeout, then escalate to -9 only if it hangs; in systemd this maps to SuccessExitStatus=143 and a TimeoutStopSec so the supervisor stops the app gracefully on its own.

Common mistakes
  • Using kill -9 by default.
  • Not handling graceful shutdown in Spring Boot.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for Linux Essentials & Shell.

Practise free

More on Linux Essentials & Shell