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

How do I know which is the parent PID and which is the child, and which one should I kill?
Who is Participating?
woolmilkporcConnect With a Mentor Commented:
in your above example you didn't find any process except for your own 'grep'.
Rather use ps -ef | grep | grep -v grep
The number in the second column (the one following the userid) is the process id. The number in the following, third column is the parent process id.
Which one to kill depends on what you're trying to achieve. Normally one would kill the actual process and not the parent!
stummjAuthor Commented:
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
stummjAuthor Commented:
Yes - that has sorted it
Kerem ERSOYPresidentCommented:
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|" | 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 | grep -v grep | xargs kill -9 $(awk '{ print $3 }')

to kill tehe parent while

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

Will kill the process (in this case

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.