Skip to content

OOM killer exception

With the following command you can create and exception on OOM killer so that it will not kill specified PID process

# OOM_DISABLE on $PID echo -17 > /proc/$PID/oom_adj

To automate the exception creation you can use the following command to retrive the pid of specific process

pgrep -f “/usr/sbin/sshd” | while read PID; do echo -17 > /proc/$PID/oom_adj; do

And you can also run as cron job

#/etc/cron.d/oom_disable

*/1 * * * * root pgrep -f “/usr/sbin/sshd” | while read PID; do echo -17 > /proc/$PID/oom_adj; done