Monday, February 21, 2022

[SOLVED] Automatically kill process that consume too much memory or stall on linux

Issue

I would like a "system" that monitors a process and would kill said process if:

  • the process exceeds some memory requirements
  • the process does not respond to a message from the "system" in some period of time

I assume this "system" could be something as simple as a monitoring process? A code example of how this could be done would be useful. I am of course not averse to a completely different solution to this problem.


Solution

For the first requirement, you might want to look into either using ulimit, or tweaking the kernel OOM-killer settings on your system.

Monitoring daemons exist for this sort of thing as well. God is a recent example.



Answered By - Avdi
Answer Checked By - Senaida (WPSolving Volunteer)