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

How do you run a Spring Boot app as a managed service and read its logs without a custom PID script?

Level III · MidLinux Essentials & Shell
Answer

Use a systemd unit with ExecStart launching the jar, Restart=on-failure with RestartSec, User= for a non-root account, SuccessExitStatus=143 so a SIGTERM exit isn't treated as a crash, and TimeoutStopSec to bound graceful shutdown. systemd then supervises restarts and you read logs via journalctl -u myapp --since '1 hour ago' instead of tailing a file. This is more robust than a hand-rolled start/stop script with a PID file because systemd handles restart backoff, log capture, dependency ordering (After=network.target), and resource limits like LimitNOFILE in one place.

Common mistakes
  • Using nohup and a PID file in production.
  • Not knowing journalctl -u service -f.

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