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.
More on Storage & Memory
How do you list disks, partitions and filesystems?IntermediateMBR vs GPT partition tables?IntermediateWalk through adding a new disk and mounting it permanently.IntermediateExplain the six fields of an /etc/fstab line.IntermediateWhy use UUIDs and `nofail` in fstab?IntermediateWhat does a bad fstab entry do, and how do you recover?Advanced