Interview Prep/Linux/Storage & Memory

How do you protect a critical process from the OOM killer?

AdvancedConceptStorage & Memory
Answer
echo -1000 | sudo tee /proc/$(pgrep -o sshd)/oom_score_adj   # never kill

Persistently in systemd: OOMScoreAdjust=-900. Use this sparingly: if everything is protected, the kernel may panic or kill something worse. A better approach is cgroup limits (MemoryMax=) so a runaway service hits its own limit and gets killed inside its cgroup, plus systemd-oomd for pressure-based userspace OOM handling.

All Linux questions Roadmap: Linux

More on Storage & Memory