Prevent Linux's OOM from killing apache on our webserver

It doesn't sound like you are addressing the root cause of the issue by actually debugging why this cron job is using up so much memory.

You can try setting this option

echo 1 > /proc/sys/vm/oom_kill_allocating_task

which will tell the OOM killer to kill the process that triggered the OOM condition, but this is not guaranteed to be your cron job. You can also use "ulimit -m" in your script to set the max amount of resident memory to use. I think your best bet would be to evaluate why the cronjob is using up so much memory and if its perhaps best suited for another host or to be rewritten to consume less memory.


The OOMKiller is configurable to an extent. After you have launched a process you can set the value of /proc/<pid>/oom_adj to a negative integer. This will affect the affinity of OOMKiller towards the process and its children . When your system hits an out of memory condition, other processes will be killed.