Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to kill runaway processes

Status
Not open for further replies.

smith364

IS-IT--Management
Jun 26, 2001
34
US
I need a script to identify runaway processes by a user. I started by using the ps -u username. I am using grep and awk. I can display the processes but I can not kill the process. Any ideas?
 
Smitty,
I would be afraid to let a script determine what a runaway process is but I do have a script to kill a process by name

#Script which will kill all processes with a given name
#
clear
echo "\n\n"
echo "Please, enter the name of the process you want to kill. \c";
read PROC_NAME
#
PID=`ps -ef | sort +6| grep $PROC_NAME|grep -v grep |awk '{print $2}'`
if [ "$PID" ]
then
`kill -9 $PID`
else
echo "I couldn't find that process name."
fi

Hope that this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top