Free ops runbook · Linux

systemd restart loops and OOM kills: read the exit code before restarting

A unit that restarts every few seconds hides the cause. systemctl status gives you the exit code; the OOM killer and the cgroup limit tell you whether the process crashed or was killed.

Exit 137 vs 143

137 usually means SIGKILL (OOM or a supervisor), 143 means SIGTERM. The code narrows the story before you read logs.

OOM evidence

dmesg | grep -i oom and journalctl -k name the killed process and the cgroup.

cgroup limits

systemctl show <unit> -p MemoryMax and the slice limits decide when the kernel steps in.

Restart loops hide logs

Rate-limit restarts and capture the first failure; a loop overwrites the evidence you need.

Detect

Read-only first

CommandWhat it shows
systemctl status <unit>Exit code, restart count, last start time.
journalctl -u <unit> -n 200 --no-pagerThe last failure, before the loop overwrites it.
dmesg -T | grep -i -E "oom|killed process"Kernel OOM kills with timestamps.
systemctl show <unit> -p MemoryMax -p MemoryCurrentConfigured limit vs current usage.
Fix

Before you raise the limit

Raising MemoryMax without understanding the leak just moves the kill to the host. Check resident-memory growth, connection pools and cache sizes first; then set the limit and the alert together.

Keep going

This page is free. The paid runbooks cover the operational failures around it, with detection commands, five failure modes and a migration checklist.