Monday, November 20, 2006

Linux : Killing processes

Sometimes you have to kill several processes generated by a service/server (the main process) and killing one process is not enough. Recently, I had trouble with 'apachectl stop'. This would not stop all the processes of httpd for some strange reason. Killing all processes by entering the process id's would take quite some time. I figured a way out -

Here's the time-saver

ps -ef | grep httpd | awk '//{print $2}' | xargs kill

You can use the same logic for other processes. You need to replace httpd with ..... you know. As you can see, awk separates just the process ids and it becomes easier for us to kill the processes !

2 comments:

Anonymous said...

pkill is more easier

pkill httpd

Ketan said...

Thanks ! pkill seems to be the thing.
These expert comments are making my blog a knowledge base. Keep visiting my blog.

Regards,
Ketan Kulkarni