Link to home
Start Free TrialLog in
Avatar of stummj
stummjFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Kill a process

I have done ps-ef  and found a particular process I need to kill.

gsmprodn 16476  9527  0 14:57:06 pts/1     0:00 grep wrapper.sh

How do I know which is the parent PID and which is the child, and which one should I kill?
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stummj

ASKER

LOL - thats annoying. I cant see the process then!
And I know its running as there are files being produced. I guess its the processes inside the wrapper I need to look for
Avatar of stummj

ASKER

Yes - that has sorted it
Avatar of Kerem ERSOY
Kerem ERSOY

In the PS -ef output the seconnd column is the pid (process ID) and third column is ppid (parent process ID). You can see the headers too with this command:

ps -aef | egrep -E "^U|wrapper.sh" | grep -v grep

Will show you columns with the heading.

If you want to do a kill then you would use the command:

ps -aef | grep wrapper.sh | grep -v grep | xargs kill -9 $(awk '{ print $3 }')

to kill tehe parent while

ps -aef | grep wrapper.sh | grep -v grep | xargs kill -9 $(awk '{ print $2 }')

Will kill the process (in this case wrapper.sh).

Cheers,
K.