Advertisements
Besides using Force Quit Applications to kill crashing or freezing applications, Mac users can also use Terminal to kill these persistent processes.
Like execution of End Process Tree in Windows Task Manager, using Terminal command to kill running process leads to the same effect (but in Terminal way).
Waste no more time, let's begin the assassination.
Within Mac OS X, there are so many running processes that identifying Process ID (PID) by wild-guess is out of the question. Luckily, there is this Terminal command called top to reveal running processes.
top
This running process analyzer can be stopped by pressing Q or Ctrl-C.
Shown Above. Running processes and their PIDs
Let's say Mail is the process to be killed with its PID 1202. To kill it, this command line can be used :
kill 1202
If there are more than one process to be killed, more PIDs can be appended to the command. For example, you want to stop Mail, TextEdit and GrowlHelper (PIDs are shown on the previous screenshot), then command line below can be used
kill 1202 968 835
The same applies for other processes with their respective process IDs.
Categories:
UNIX, Open Source
Tags:
Kill,
Terminal
Some articles taken from our resource base, tightly related to current article, to empower you with more knowledge on tweaking the most out of your Mac.
Or you can just type in killall Mail and don't have to look for the PID.
also there is no need to write:
kill PID 36670
PID is not needed which leaves us with:
kill 36670
Lol, again: terminal is really amazing!
It's better to quit `top` by hitting 'q' or C-d. C-z only suspends top and it continues running in the background (enter `jobs` to see the currently running programs that have been suspended by C-z, use `fg` to restart top in the foreground after hitting C-z, or use `bg` to tell it to run in the background).
Thanks. I've just realized that the process is still running on the background. I think now I should update this article.
An easier way of finding the PID is to run Activity Monitor. If you set the drop down to show 'All Processes' you can see all the running apps, and sort by name or CPU usage (for example) to spot the one you are looking for. Activity Monitor reports the PID for each process. So then you can simply open terminal to run the kill command...
However... an even easier next step is in Activity Monitor to simply select the process (or processes - use Apple+click to select multiple rows) you want to kill and then click the big red "Quit Process" button - which will then ask if you want to soft quit (same as Apple+Q) or force quit (i.e. kill) the process(es).
As with many things on the Mac, it is nice to know that you can find a complex way to do things, but usually you don't need to - just use the tools already provided :)
It might also be worth noting that 'top -o cpu' gives you the running processes sorted by amount of cpu currently used (helpful to identify runaway processes hogging the cpu).
I've been using both Activity Monitor (usually to confirm that a process is not responding) and also just ctr-alt clicking the application on the dock then clicking "Force Quit." The thing I miss most from Linux, however, is an app which turns the cursor into a skull and crossbones with which one can simply click on an offending window and kill the process responsible. I generally launched this feature with a key command, which made it really convenient (albeit I admittedly needed to avail myself of it more frequently in Linux than I would with OSX!).
I've also read that you can use "kill -9 [pid]" which basically means end the process no matter what. I think you can use that if the regular kill command doesn't work. Just something I remember...might not be relevant.
Anyone know how to scroll (or get to the bottom) of the top list ? Sometimes my list is so long that i can not see all processes.
kill all your processes: $ ps -o pid -u username | xargs kill there will be one error message, doesn't matter.
Leave a Comment