brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: journalctl -k -g finds which process the OOM killer took

Journalctl
~/tips/tip-journalctl-oom-kills

journalctl -k -g 'killed process' --since "2 days ago"

Find out which program the kernel killed when memory ran out.

A service that disappears without an error of its own was often killed by the kernel for using too much memory. The kernel says so in its log.

Search the kernel messages for the line it prints when it kills something:

journalctl -k -g 'killed process' --since "2 days ago"

In the kernel source that line reads Out of memory: Killed process 1234 (name) total-vm:..., followed by the memory use of the victim. When a container or a service with MemoryMax= hit its own limit, the reason says Memory cgroup out of memory instead. Because my pattern is all lowercase, -g matches case-insensitively and catches both.

A few lines above it the kernel logs an oom-kill:constraint=... line that tells you whether the whole machine or just one cgroup ran out. To read the full report, jump to the hit and look around:

journalctl -k -b -g 'oom-kill' -n 5 -o short-precise

On the systemd side, the unit shows up as failed with the result oom-kill in systemctl status.

On desktops and Fedora style systems, systemd-oomd may kill things before the kernel does. Those kills are not kernel messages, so this search misses them; check journalctl -u systemd-oomd as well.

Further reading: journalctl man page, Linux kernel source, mm/oom_kill.c

More Journalctl tips journalctl _PID=1 -b ls -lh /var/log/journal/*/*.journal~ Storage=volatile sudo journalctl --setup-keys journalctl -F _KERNEL_SUBSYSTEM All Journalctl tips (81) All topics

Link