Sorry, I should have been clearer. Let's say you run the monitor in
cron every 10 minutes:
- try to open /tmp/monitor_info
- if non-existent, generate pid/procname list, write to /tmp/monitor_info and exit
- read file data into array/hash
- generate pid/procname list using aforementioned ps command
- compare lists. If same pair shows up in both, kill it (it's been running longer than 10 minutes).
- write new list to /tmp/monitor_info
Adjust cron interval to be a time comfortable to ensuring that process is broken. It is a little more complicated if you have processes that have different 'comfort intervals', but you could simply include a count to each line in
/tmp/monitor_info to manage this.
This script is short and easy. Does that make sense?
fnord