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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Korn Script to kill processes by pid

Status
Not open for further replies.

warburp

IS-IT--Management
Oct 27, 2003
44
GB
Hi

No doubt a straight forward request for those who are used to lots of programming. I have a number of scripts which store their pid in a file when running. I want to display on screen the pid and the pid desciption so that a user can select a pid (script) to terminate.

Anyone point me in the direction of a script I can use or give me some pointers.

Thanks
 
I have used this script to quickly kill all java processes on a development system. Since you already have the PID file, you could take just the part from the cat line on down:

PID=`ps -e | grep $1 | awk '{ print $1 }' > /export/home/utility/bin/pid.txt`

# This line cats the file created in the line above and says while
# catting the file, read each line.

cat /export/home/utility/bin/pid.txt | while read LINE

# This line tells the system to do a kill -9 on each PID that is
# listed in the pid.txt file. There will alwasy be an error message
# because the grep for the process is also listed but by the time
# the kill command is executed, the grep has already died.

do kill -9 $LINE
# This line closes up the do line.
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top