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

I Need a Script to read a process in AIX

Status
Not open for further replies.

yaway

IS-IT--Management
Aug 7, 2003
12
US
I need help in building a script that will read the PID of a process and then kill that process. If anyone can help me I would be greatful.

Thank You
 
I've used this:

#!/bin/ksh
# This line gets the process number for the value passed in the
# command (java, for WebSphere) and writes the PID only to
# a text file.

PID=`ps -e | grep $1 | awk '{ print $1 }' > /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 /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


The command syntax is:

scriptname.sh process_name

Check to make sure what your output is for ps -e and test!
 
Thank You Very Much. This is a big help.

Yaway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top