View and send signals to active processes
Author: hubertf contact BSD flavour
Reviewer: name contact BSD flavour
Reviewer: name contact BSD flavour
Concept
Be familiar with both the names and numbers of the most commonly used Unix signals(((signals))) and how to send a signal to an active process. Recognize the difference between a SIGTERM(((SIGTERM))) and a SIGKILL(((SIGKILL))).
Introduction
Section Determine which process are consuming the most CPU talks about processes, and how to list and manage them. This topic is covered in a bit more depth here, by listing other tools besides kill(1):
pgrep(1)(((pgrep))): Many times you will find yourself wanting to look for a certain process, using a pipeline of "ps ... | grep ...". The pgrep(1) command automates this - you give it a programm name, and it will print the process ID of the process(es) that match the command name. This command is available on all BSD systems.
pkill(1)(((pkill))): Like pgrep(1) this command looks throught the list of processes running on a system, and sends a certain signal to all processes matching a given name.
killall(1)(((killall))): This command performs the same operation as pkill(1). It is only available on FreeBSD, its existance predates that of pkill(1).
Examples
See section Determine which process are consuming the most CPU for examples on using ps(1) and kill(1). The following example achieves the same goal with the commands introduced here:
# pgrep -lf named
338 /usr/sbin/named -u bind
# pgrep named
338
# kill named
# pgrep named
#
Practice Exercises
See section Determine which process are consuming the most CPU and perform the same tasks with pgrep(1) and pkill(1).
More information
ps(1); kill(1); killall(1); pkill(1); pgrep(1)