[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] Proccesses not dieing



Here's the version that doesn't use any temp files.


********* CUT HERE ***********


#!/bin/sh

# Loop for each process not belonging to root
for process in `ps ux | grep -v 'root' | awk '{print $2}'`
do
kill $process
done

********* CUT HERE ***********

--TP


Terrell Prude', Jr. wrote:


Try the following script. It kills off every process except root. Don't know how portable it would be to other UNIXes, but I figure it should run fine on *BSD too. When you really mean business, just change "kill $process" to "kill -9 $process". BTW, yes, it's a very quick hack; I'm sure someone could do it w/o dropping a temp file.


********* CUT HERE ***********


#!/bin/sh

# Get a list of all user processes not belonging to root
# store them temporarily in a file called scratchpad.txt
ps ux | grep -v 'root' | awk '{print $2}' > scratchpad.txt

# Kill each process whose pid is in scratchpad.txt
for process in `cat scratchpad.txt`
do
kill $process
done

# Clean up
rm scratchpad.txt

********* CUT HERE ***********

Hope this helps,

--TP

Matt wrote:

Hi,
Got a small problem here.
It seems that after being up for 26 days.. the system has begun to get
sluggish.. apon investigation it appears that there are user proccesses
(mozilla, etc) that are not completely closing out.. even when the user
logs out.. and they are still running in the background. Does anyone
know a way to stop this? Or has anyone written a script to kill
proccesses belonging to users every night that I could run in a cron? Any ideas?










[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]