Quote:
does that kill the process no matter how long its running, or only if its over a certain "age" or idle for so long?
|
If you look at a line from
ps aux like:
Code:
cam 18555 4.3 0.1 345992 6736 ? Ssl 11:27 0:43 /usr/bin/pulsea
the tenth field is the time elapsed - 0:43 in the example above. It's in HH:mm format.
sed strips the : out of the line, and
awk checks to see if the value of the tenth field ($10) is > 100 ie 1 hour 00 minutes, (this was what you asked for) and "prints" the process number (second field, $2) to the
kill command, which may or may not kill it. You could put $10 > 200 for 2 hours or $10 > 30 for 30 minutes.
kill -1 often won't kill hung processes -
kill -9 will, but without tucking them into bed nicely.
kill -3 might be about right. See
man kill
However, you're probably better following unSpawn's advice than mine.