BSD Newsletter.com
   Front | Info | Lists | Newsfeeds | Study Guide | What is BSD?
Advertisement: The OpenBSD PF Packet Filter Book: PF for NetBSD, FreeBSD, DragonFly and OpenBSD

BSD Links
·New Links
·Advocacy
·Drivers
·Events
·Flavours
·FAQs
·Guides
·Programming
·Security
·Software
·User Groups

This is the BSDA Study Guide Book written via a wiki collaboration. This is a work in progress. You may contribute to or discuss this specific page at http://bsdwiki.reedmedia.net/wiki/View_and_send_signals_to_active_processes.html.

View and send signals to active processes

Concept

Be familiar with both the names and numbers of the most commonly used Unix signals and how to send a signal to an active process. Recognize the difference between a SIGTERM and a 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): 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): 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): This command performs the same operation as pgrep(1). It is only available on FreeBSD, its existance predates that of pgrep(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)



Front | Information | Lists | Newsfeeds