Thursday, May 16, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 3712  / 2 Years ago, sat, may 28, 2022, 1:47:24

Is there a way to set the OOM killer adjustment value right when a daemon process (Apache in my case) starts? I would like to give the Apache processes a higher likelihood of being killed and make it virtually impossible for some more vital services to be killed by the OOM killer.


More From » memory-usage

 Answers
3

I think you best bet would be to add a separate script as part of your init.d. In it, you will want to do something like this



echo 15 > /proc/`pidof APP_NAME`/oom_adj


The pidof APP_NAME will retrieve the process ID of the app with that name. Writing 15 to /proc/{pid}/oom_adj ups the "badness" of process {pid}, making it more likely to be killed by OOM killer.



The article Taming the OOM killer from LWN.net also hints at some other ideas that were suggested to allow specification of an "oom_victim", but I am not sure any of them are actually in the kernel.



BTW: The best solution would be to avoid having to use the OOM Killer in the first place. Remember Micro$oft's unwritten motto: There's no problem more RAM can't fix.



[Note: If there could be more than one of these processes, you may want to revise the code a bit.]


[#44394] Saturday, May 28, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ipentainer

Total Points: 112
Total Questions: 113
Total Answers: 113

Location: Guernsey
Member since Tue, Jul 6, 2021
3 Years ago
;