Solved

Kill question

Posted on 2008-09-30
9
347 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
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 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…
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.

914 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now