1833480 Members
2862 Online
110052 Solutions
New Discussion

kill script --

 
SOLVED
Go to solution
rmueller58
Valued Contributor

kill script --

If you want to kill all processes related to a specific user we set up the following..

# killit /usr/local/bin/killit
# ESU#3 - Systems and Networking
# rcm(10/03/2001)
# this script was written to kill hung users
#
#==============================================
# BEGIN SCRIPT
ps -ef |grep -v -f /usr/local/bin/patt.1 |grep $1 > temp.1
kill -9 `awk '{print $2}' temp.1`
rm temp.1
# END SCRIPT
#==============================================

note ** /usr/local/bin/patt.1 file contains patterns that you want to avoid. it allows you to exclude items that you want to avoid killing..

Hope it helps..
4 REPLIES 4
Elmar P. Kolkman
Honored Contributor
Solution

Re: kill script --

Why not something like this:
su -c kill -9 -1 ?

Only make sure user is not root, otherwise it will kill a bit too much... ;-)
Every problem has at least one solution. Only some solutions are harder to find.
John Poff
Honored Contributor

Re: kill script --

Hi,

Why do a 'kill -9'? Why take a chance on hosing up your system with the most dangerous kill signal first?

I'd suggest doing a 'kill -15' first, testing for the result, and then doing a 'kill -9' if that fails.

JP
rmueller58
Valued Contributor

Re: kill script --

Elmer,

I was posting to another thread.. creating this new thread was a mistake. the problem they were having was specific to certain processes..

I appreciate the script you posted I will add it to my library and will definitely use it.. It will come in handy. Thanks!! Rex
rmueller58
Valued Contributor

Re: kill script --

John,

Good point on trap siglevel.. the items we were "killing" we wanted dead, dead.. I do believe adding the traps for additional levels will definitely add something to this script and reduce possible problems.

Thanks..

Rex