GrepBoard/Manuals
605 manuals ·

Find the process the OOM killer killed on Ubuntu 24.04

·Tested on Ubuntu 24.04.5 LTS · systemd 255 · Linux 6.8.0-147 (log line shapes from the kernel 6.8 format strings)·Test scope ↓·7 steps

Search journalctl -k and dmesg for OOM killer records when a service vanishes, then read the victim and whether a system shortage or a cgroup limit caused it.

If a service disappeared with no log line and systemctl status only says Main process exited, code=killed, status=9/KILL, look for a kernel OOM killer record first. The log lines below were not produced by a real OOM event. They are hand-written examples that follow the format strings of kernel 6.8.0-147. Host name and PIDs are made up.

[1] Search the kernel messages for Killed process. -k shows kernel messages only, for the current boot. -g takes a regular expression; if the pattern is all lowercase, matching is case insensitive.

console
# journalctl -k -g "Killed process" -o short-iso --no-pager2026-11-03T02:14:07+09:00 server1 kernel: Out of memory: Killed process 3391 (mysqld) total-vm:8575488kB, anon-rss:7207600kB, file-rss:848kB, shmem-rss:0kB, UID:110 pgtables:14576kB oom_score_adj:02026-11-03T09:40:51+09:00 server1 kernel: Memory cgroup out of memory: Killed process 5120 (node) total-vm:1612340kB, anon-rss:524100kB, file-rss:9120kB, shmem-rss:0kB, UID:1001 pgtables:1480kB oom_score_adj:200

[2] If the server rebooted right after the OOM, look at the previous boot. -b -1 is the boot before the current one, and --list-boots lists the boots the journal still holds. If the earlier boot is not listed, the record is not in the journal.

console
# journalctl --list-boots# journalctl -k -b -1 -g "Killed process" -o short-iso --no-pager

Narrow by time with --since "2026-11-03 00:00". If old records are missing, check the retention limits in journald disk usage and vacuum.

[3] Read the line. The Killed process line is the victim:

FieldMeaning
3391 (mysqld)PID and process name
anon-rssanonymous memory (heap, stack) the process held; usually the biggest value
file-rss · shmem-rss · UIDfile mappings · shared memory · owner
oom_score_adjadjustment added to the kill-candidate score

The prefix Out of memory: means the whole system ran short. Memory cgroup out of memory: means a cgroup memory limit was hit.

[4] Look at the lines just before the kill. Save the journal to a file and use grep -B for the context.

console
# journalctl -k -o short-iso --no-pager > /tmp/kern.log# grep -nE 'invoked oom-killer|oom-kill:|Killed process' /tmp/kern.log | cut -c1-150

The line <name> invoked oom-killer: gfp_mask=…, order=0, oom_score_adj=0 names the process that asked for memory and triggered the OOM. It can differ from the victim. The oom-kill: line below it packs the cause.

output
oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/system.slice/mysql.service,task=mysqld,pid=3391,uid=110

global_oom means system-wide shortage. For a cgroup limit, oom_memcg= appears in its place. task_memcg= is the cgroup of the victim — the service unit path.

[5] With many records, reduce each to one line: time, PID, name, anon-rss.

console
# awk '/Killed process/{ for(i=1;i<=NF;i++) if($i=="process"){pid=$(i+1);name=$(i+2)} match($0,/anon-rss:[0-9]+kB/); print $1, pid, name, substr($0,RSTART+9,RLENGTH-9) }' /tmp/kern.log2026-11-03T02:14:07+09:00 3391 (mysqld) 7207600kB2026-11-03T09:40:51+09:00 5120 (node) 524100kB

[6] Where there is no journalctl or the journal does not keep kernel messages, use dmesg. -T prints human-readable timestamps.

console
# dmesg -T | grep -E 'Killed process|invoked oom-killer'

[7] If there is no kernel record but the process died from SIGKILL, suspect systemd-oomd. It watches cgroup v2 and PSI (memory pressure), picks a cgroup over its limits and sends SIGKILL to every process in it, acting before the kernel OOM killer. So read the unit log, not Killed process lines.

console
# systemctl status systemd-oomd# journalctl -u systemd-oomd -o short-iso --no-pager# oomctl

oomctl shows the monitored cgroups and their pressure. Only units with ManagedOOMSwap= or ManagedOOMMemoryPressure= set to kill are candidates.

Analyze your syslog · journal log in the browser ↗ — nothing is uploaded.

#oom#journalctl#dmesg#memory