I'm looking for a way to kill all processes with a given name that have been running for more than X amount of time. I spawn many instances of this particular executable, and sometimes it goes into a bad state and runs forever, taking up a lot of cpu.
I'm already using monit, but I don't know how to check for a process without a pid file. The rule would be something like this:
kill all processes named xxxx that have a running time greater than 2 minutes
How would you express this in monit?