UsingMac.com

Mac Tricks and Tips, Wallpapers and Applications for Mac Users

Terminal Kills Process

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.

Identify Running Processes

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

Kill Identified Processes

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

Subscribe to RSS Leave a Comment (12)

Related Entries

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.

12 Comments

msb

Or you can just type in killall Mail and don't have to look for the PID.

xonic

also there is no need to write:
kill PID 36670
PID is not needed which leaves us with:
kill 36670

NaVi

Lol, again: terminal is really amazing!

Anon

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).

Wendy

Thanks. I've just realized that the process is still running on the background. I think now I should update this article.

Gavin

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 :)

Patrix

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).

jhm

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!).

Shaun

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.

jay

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.

augix

kill all your processes:

$ ps -o pid -u username | xargs kill

there will be one error message, doesn't matter.

nelo

when i use de the 'top' command in a terminal windows of 1000 pixels height i can see more process, but if i have a window of just 500 i see just half and i can scroll down to see the rest.

how i page down the top command, i tried many keys and i can't find the way to do it.

Leave a Comment