LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] kill process by name

[ILUG] kill process by name

David Neary dneary at wanadoo.fr
Tue Jul 16 13:03:55 IST 2002


Kenn Humborg wrote:
> > ps -ao pid,args | grep 'command' | awk '{print $1}' | xargs kill
> 
> There is nothing to prevent the grep command itself being killed
> before it finishes.

Good point. That grep could be changed to 
grep '[c]ommand'
or something similar that won't match itself.

> but in a script you need to be much more careful.  Some of the
> processes you want to kill just might have 'grep' in their
> command name or arg list.

Yes, hmm... I can't see any nice way to get around this with
shell hackery on $1. If the script is called with (say)
kill_foo '[^.]\<java\>'
to avoid killing javac processes, and java_vms (or whatever), and
editors editting .java files, then the grep wouldn't work on
itself, but to prevent it from working on itself in general, you
need to do some tomfoolery to restrict the class of regexps it
can take. Hmmm...

Good point.

Cheers,
Dave.

-- 
       David Neary,
    Marseille, France
  E-Mail: bolsh at gimp.org




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell