[comp.unix.shell] Killing run away processes

r3jjs@VAX1.CC.UAKRON.EDU (Jeremy J Starcher) (10/03/90)

#!/bin/sh
#########################################################################
#  This shell script will zot (kill -9) all process except the user's	#
#  shells. Several processes will return as none existent or some other #
#  error.  Ignore those.						#
#									#
#  This script file is dedicated to all those who find themselves with	#
#  a program that quickly goes out of control and need a way to		#
#  terminate it quickly.						#
#								  	#
#  Caveat:  This script must be named zot                               #
#									#
#  Author:  Jeremy J Starcher (r3jjs@vax1.cc.uakron.edu)		#
#  Date:    2 October 1990						#
#########################################################################

kill -9 `ps -aux | grep $USER | grep -v -e -csh | grep -v 'sh zot' | cut -c10-15 | paste -s -`

rickert@mp.cs.niu.edu (Neil Rickert) (10/07/90)

In article <708@VAX1.CC.UAKRON.EDU> r3jjs@VAX1.CC.UAKRON.EDU (Jeremy J Starcher) writes:
>kill -9 `ps -aux | grep $USER | grep -v -e -csh | grep -v 'sh zot' | cut -c10-15 | paste -s -`

  When our current system was installed about 5 years ago, someone wrote what
he thought was a simple program:
  It and all of its children finished up in infinite forking loops.

  Have you tested your script on such a beast?

-- 
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  Neil W. Rickert, Computer Science               <rickert@cs.niu.edu>
  Northern Illinois Univ.
  DeKalb, IL 60115.                                  +1-815-753-6940

r3jjs@VAX1.CC.UAKRON.EDU (Jeremy J Starcher) (10/08/90)

I posted a shell script that should kill all process except the shells,
and was asked if it would work on runaway processes (spawing messes)..

To answer.. I am not sure..

Since I have never seen a run away process and our local VAX god would not
be pleased if I started one (ie. I might loss my account), I cannot say.

If the process does not spawn too quickly, it should.  

PS.  Depending upon local preformance, changin the 'grep' to 'egrep' might help
out quite a bit..


-- 
--------------------------+---------------------------------------------------
Jeremy J Starcher         !  No programmer programs in LOGO after reaching
r3jjs@vax1.cc.uakron.edu  !  age 14...
r3jjs@akronvm.bitnet      !

hansm@cs.kun.nl (Hans Mulder) (10/09/90)

In article <708@VAX1.CC.UAKRON.EDU> r3jjs@VAX1.CC.UAKRON.EDU (Jeremy J Starcher) writes:
>#!/bin/sh
>#########################################################################
>#  This shell script will zot (kill -9) all process except the user's	#
>#  shells.	 							#

Moreover, it will also kill all the user's shells, except maybe their
login shell if it happens be named csh.  It will also kill their
window system if they use one, preferably leaving their terminal
in an unusable state.

>#  	    Several processes will return as none existent or some other #
>#  error.  Ignore those.						#

You don't like reliable software, do you?

>#  Caveat:  This script must be named zot                               #

Translation: "zot" is the Dutch word for "fool".

>#  Author:  Jeremy J Starcher (r3jjs@vax1.cc.uakron.edu)		#
>#  Date:    2 October 1990						#
>#########################################################################
>
>kill -9 `ps -aux | grep $USER | grep -v -e -csh | grep -v 'sh zot' | cut -c10-15 | paste -s -`

Ignore in particular any messages "sh: cut: not found" and "sh: paste:
not found".  Those merely indicate you live in BSD land and you knew
that already.

Have a nice day,

Hans Mulder	hansm@cs.kun.nl