Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Kill question

Posted on 2008-09-30
9
Medium Priority
?
358 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

705 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