Solaris Advanced User's Guide

Terminating Processes (pkill)

Most window environments have a tool for managing processes. See the tool's online help if you need information on using it.

You can use the pgrep and pkill commands to identify and stop command processes that you no longer want to run. These commands are useful when you mistakenly start a process that takes a long time to run.

To terminate a process:

  1. Type pgrep to find out the PID(s) for the process(es).

  2. Type pkill followed by the PID(s).

The following example illustrates how to find all the processes with a specific name (xterm) and terminate the xterm process that was started last.


$ pgrep xterm
17818
17828
17758
18210
$ pkill -n 18210
$

If you need to forcibly terminate a process, use the -9 option to the pkill command.


$ pkill -9 -n xterm