We are running a job where we know it squeezes the memory sometimes a bit too much. This however is resulting in killing one or two processes that we want to be the last processes killed in such a situation. How do we tell linux, please please do not kill pid XXXX and pid YYY and kill the other jobs first including that job taking up all the CPU if necessary as that job(the one we are running) is lower priority for survival than the two other processes.

Basically we are running a map/reduce job with our cassandra database and linux is deciding to kill cassandra instead of killing map/reduce tasks(which would be ideal since they have recovery built in and can black list tasks as well).


You can set priorities for which processes the OOM Killer will terminate.

Give a process a negative oom_adj value to make it LESS likely to be killed:

echo -15 > /proc/2592/oom_adj

Give it a positive value to make it more likely to be killed:

echo 10 > /proc/2592/oom_adj

Replace 2592 in the above commands with the actual PID's of the processes you want to protect and/or sacrifice.


You can:

echo -18 > /proc/$PID/oom_adj

Hope this helps

  • maayke, whilst we value answers which give references, we definitely prefer answers that include substantive content instead of just linking to off-site material. One reason is that substantive articles stay helpful long after their links have rotted. May I encourage you to flesh out your answer, perhaps with a quick precis of the LWN article? – MadHatter Sep 18 '13 at 12:54
  • 1
    Sure, next time I'll remember. – maayke Sep 18 '13 at 13:24

If you want the process that triggered the OOM to die, just set the appropriate sysctl:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.