Solved

Kill question

Posted on 2008-09-30
9
355 Views
Last Modified: 2012-05-05
Can a wildcard (*), be used with a kill statment?

for example, if you wanted to kill all process starting with 123, could you run kill 123*

or to kill all process, could you type

kill*
thanks
0
Comment
Question by:loserbrewer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 15

Expert Comment

by:alienvoice
ID: 22611747
From my experience you cannot do a straight 'kill -9 *'

You can issue a 'killall' command, but I'd becareful issuing it.

Do a 'man killall' for further information on this command.

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 22611968
if you wand to do similar thing, then you may filter the processes ids (e.g. using grep) then use kill to terminate processes:

for pid in `ps -ef | grep -v -i ppid | awk '{ print $2 }' | grep ^123`
do
   kill -9 $pid
done

or

kill -9  `ps -ef | grep -v -i ppid | awk '{ print $2 }' | grep ^123`



0
 
LVL 48

Expert Comment

by:Tintin
ID: 22612031
What practical purpose do you have for needing this?

If your system has pkill, I'm sure you'd find that a lot more useful.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:kishored2004
ID: 22612125
The kill command should be used with utmost caution unless you have the luxury of playing around..All said and done you should always try to kill the process gracefully first with the normal kill command before using the kill -9 which will do a forceful kill.

I also feel as said above...just grep on the process and use a normal kill. If that doesnt work do a forceful kill.
0
 

Author Comment

by:loserbrewer
ID: 22614981
This was more of a theoretical question. I am just learning UNIX and dont have a system I can work on.

So, does any one think a Kill command will work with a wildcard?
0
 
LVL 6

Expert Comment

by:IncisiveOne
ID: 22616425
No.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 22618852
Short answer no.  Longer answer, I can't think of any possible practical purpose for this, hence my question about what you wanted to use it for.

pkill is much more useful as it allows you to kill processes based on their name.
0
 

Author Comment

by:loserbrewer
ID: 22618969
Thank you for the responses. Anyone know what would happen if you ran kill*, would you get an error or would it look for a process called "*"
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 22619049
The * would be expanded (it's called shell globbing) to all the files/dirs in the directory you are running the command from.

For example, if your current directory has the following files

foo
bar

then kill * gets expanded to

kill foo bar
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question