0

I'm trying to kill process by name. It's supposed to kill children processes first then the parent later but I only get parent killed. Help needed please. EDIT: SOLVED

A. Koo
  • 5
  • 2

1 Answers1

0

Please try it this way:

PID=$(ps -aef | grep `whoami` | grep $argument | grep -v grep | grep -v $$ | awk '{print $2}'
for x in ${PID[@]}; do
  CPID=$(ps -aef | grep `whoami` | grep $PID | grep -v grep | grep -v $$ | awk '{print $3}'
  for y in ${CPID[@]}; do 
    kill $y
  done
  kill $x
done
GMichael
  • 2,726
  • 1
  • 20
  • 30