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!

killing PID with a script 1

Status
Not open for further replies.

june54

Technical User
Jun 4, 2003
160
US
I am running AIX 5.1.3 We have a product that has a startup but no shutdown the only way to stop it is to kill the PID ...I need to have this set to stop automatic . How would I write my script to kill this job ....

Thanks
 
This is what I have used in the past. It was used in some WebSphere development when the only way to shutdown WebSphere if you weren't on the WebSphere console was to kill all the java processes.

Syntax for executing the script is:

myscript.sh <process>

# 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 may 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