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.