Monitoring Processes - Killing hung processes

Is there a way to monitor certain processes and if they hang too long to kill them, but certain scripts which are expected to take a long time to let them go?

Thank you
Richard

what do you mean by "hung"? What is the problem that the "hung" processes are causing. Some processes run from system boot to the next halt/reboot. You really don't want to blindly kill processes.

i dont know what you mean by "hang" but when my solaris OS is getting really slow responding and seeing that the CPU load is almost always 100% the first thing i would do is execute "prstat" to check which process is taking up load in the CPU. i would kill the process only if i knew that it is not important ie. from users etc. - check the owner in the "prstat" output.

you said it

your box might not be the right size for what your needs are. You may want to implement resource limits or something. If you set a cpu time limit then the OS would kill the processes for you.

How to categorize them actually ?

To be on the safer side for these kind of problems; a safe and reliable approach would be to,

if possible make the process which needs to be monitored dump some [DEBUG] messages, [INFO] messages every 'n' time slice to an unique log file

With that it would be quite easy to track the status of the process by parsing the log file that is specific to each of the process that needs to be monitored.