views:

1117

answers:

6

My Mac becomes slow over time. The reason is the huge amount of my shells, such as Bashes and Fishes. Each shell has different PID. Killing shells one by one is too cumbersome. How can I kill them at once?

+12  A: 

The killall command can kill all processes with a given name:

killall bash
Robert Gamble
Doesn't this endanger the shell from which it is run?
Jonathan Leffler
Also, this is linux specific. Older unixies had differnet symantics for "killall".
dmckee
Um. Actuall it works in Mac OS X as well.
dmckee
@Jonathan: Yes, if the shell the example is run from is a bash shell then it will be killed as well, from the question this appears to be the desired behavior.
Robert Gamble
"appears to be the desired behavior": at least it is the one he asked for...which is not always what is actually desired...
dmckee
@Robert: I guess "be careful what you ask for; you might get it" is roughly what applies. The caveat has now been given to the questioner by these comments. :D
Jonathan Leffler
+1  A: 

Know the filename of the executable? You can use "killall " on many Unix systems.

# killall <name>
rjamestaylor
+7  A: 

Try 'killall bash' or 'killall -9 bash' if they resist that.

nrl
+7  A: 

As per other answers, the usual command is killall.

Note though that on some versions of UNIX (e.g. DEC Unix) this command literally kills all processes.

Do make sure that you know which behaviour your UNIX has before using it!

Alnitak
Where are the codes for killall and kill in my comp for inspection?
Masi
kill -l generally lists all signals.
Keltia
HL, have you considered just reading `man killall`?
dmckee
@Keltia, signals and kill(1) are completely irrelevant to this question/answer.
Dave C
A: 

I think that you cannot kill all your Shells at once. You have to use many killalls, separately to each Shell like Rjamestaylor says above:

killall bash
killall fish

And so on.

Masi
Well, if you're executing this from a bash shell (the default on OS X), you'll want to run those two commands in the opposite order. :-)
Ben Blank
+4  A: 

I strongly doubt your initial diagnosis. In Unix, an inactive process does not take resources. It is not scheduled, its memory is swapped out, etc. If there is a problem of slowness, it probably has another cause. Running top is the first step.

bortzmeyer
The Fish shell, probably a beta, consumes almost all of my CPU. It is shame as Fish is easy to use. I like the colours.
Masi