"Rodney C. Marable" <marable@firefly.net>
Amol Karnik <amol@memcad.com>
djohnson@nbserv2.dseg.ti.com (Danny Johnson)
Arthur Darren Dunham <add@netcom.com>
CASALME RENE B <rene.casalme@hsc.hac.com>
rene@iusti.univ-mrs.fr (Mr Rene Occelli)
anders@hmi.de (Thomas Anders)
Jochen Bern <bern@TI.Uni-Trier.DE>
"Iskander, Tim" <ISKANDER@infimed.com>
Joseph S D Yao <jsdy@gwyn.tux.org>
"B C Hamshere" <B.C.Hamshere@newcastle.ac.uk>
Michael Hill <Michael_Hill@csgsystems.com>
My original question
--------------------
Howdy folks. We have a server (running Solaris 2.5.1) which keeps getting
clutter up with orphan processes (from users not logging off nicely and/or
network problems) till it runs out of swap. So I was wanting to write a script
that runs nightly and kills any (user) processes that's older than say 30 days.
But I was wondering how others do it, if there is a better way than running a
script in this manner. Thanks in advanced.
Summary of responses
--------------------
Arthur Darren Dunham <add@netcom.com> suggested I try "ethanasia" but I couldn't
find it.
--- CASALME RENE B <rene.casalme@hsc.hac.com> send the command ps -ef|grep <process>|grep -v grep|awk '{if ($3 =="1") print $2}|xargs kill -9 which works and can be used as a script.--- "B C Hamshere" <B.C.Hamshere@newcastle.ac.uk> sent me the script #!/bin/sh MINUID=nnn # lowest uid number, minus one MAXAGE=30 HITLIST=`find /proc -mtime +$MAXAGE -user +$MINUID -print |\ awk -F/ '{ print $3 }'` kill $HITLIST--- anders@hmi.de (Thomas Anders) suggested I use a wrapper like cputime to limit running times of programs.--- Michael Hill <Michael_Hill@csgsystems.com> sent me the code for prowarn.c which does exactly what I was hoping my script to do and more. It can be setup to either warn users of processes that has been idled for too long or it can be setup to kill without warning.--- The following people suggested I look into the idled package: Amol Karnik <amol@memcad.com>, URL = http://www.darkwing.com/idled "Iskander, Tim" <ISKANDER@infimed.com>, URL = ftp://ftp.cs.hope.edu/pub/idledThe Idled turns out to be the most complete package with all sorts of options. I am in the middle of installing and testing this product but this seems to be the best and complete solution.
Thanks again to everyone who responded.
Thomas.