Solved

Kill question

Posted on 2008-09-30
9
340 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
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.

762 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

19 Experts available now in Live!

Get 1:1 Help Now