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!

pkill equivalent command in AIX 1

Status
Not open for further replies.

pdtak

Technical User
Feb 25, 2008
63
US
Does anyone know how I can find a process and kill it using one command line (ie. ps -ef | grep process; get PID; kill -9 PID)?
I know in Solaris there's a pkill command, but I didn't find a pkill command in AIX.
I like to run it in a script. How can I do this?
Thanks.
 
Not sure if it will work put try this:

Code:
 pid=`ps -e |grep "process_name" |sed -e 's/^  *//' -e 's/ .*//' &&[ ! -z "$pid" ] && echo killing Process_name && kill $pid &

Replace the process_name with your process.

Regards,
Khalid
 
Thanks for your tip Khalidaaa.
I tried your command, but I got a syntax error:
pid=`ps -e |grep tftpd |sed -e 's/^ *//' -e 's/ .*//' &&[ ! -z "$pid" ] && echo killing Process_name && kill $pid & >
Interrupt Received
sh: 0403-057 Syntax error: ``' is not matched.
 
looks like you need the ` at the end. I see this one pid=`ps -e but not another one.
 
create a little function for pkill and dump it in your .profile:

function pkill {
PIDTODIE=${1}
for die in `ps -ef|grep $PIDTODIE|grep -v grep|awk '{print $2}'`;do
echo $die
done
}

replace echo with kill, once you feel safe.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top