Greater grokking of pgrep

Using the pkill Command

A common reason for locating a process is that it is misbehaving or not responding and needs to be shut down. Pkill [2], which originated in Solaris just as pgrep did, simplifies this set of tasks by using options and extended regular expressions in the same way as pgrep. However, as with kill or killall, pkill includes the option to terminate results with SIGKILL (2), so that one command does the job of two.

Entered without any options, pkill closes all processes that match results. Used carelessly, the pkill command can easily crash a system by closing a core process, meaning that, the more precise the pattern in the command, the less likely something unexpected will happen.

Unlike pgrep, pkill also includes the option --signal SIGNAL, which allows the sending of any other signal [3]. Most users will probably have few uses for this option, although on a network, a system administrator might use SIGINT (15) to close down the terminal of a misbehaving process or SIGCHILD (17) to close down a child of a parent process.

For most users, pkill is an extra with limited use. But, whether you administer one computer or thousands, pgrep is a much-needed addition to your toolkit. Learn even a handful of its basic options and tracking down processes becomes far easier.

The Author

Bruce Byfield is a computer journalist and a freelance writer and editor specializing in free and open source software. Bruce's most recent book, Designing with LibreOffice, was released under a Creative Commons License in March 2016. You can buy or download his book at http://designingwithlibreoffice.com/download-buy/. In addition to his writing projects, he also teaches live and e-learning courses. In his spare time, Bruce writes about Northwest Coast art. You can read more of his work at http://brucebyfield.wordpress.com.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Welcome

    We are living with an embarrassment of choice. Small-board computers (SBCs) are getting smaller and faster, with many inexpensive options for the hobbyist and problem-solvers and more powerful, usually pricier, options for inventors, innovators, and CPU-guzzling consumers. New SBCs are entering the market continuously, it seems.

  • Testing a Pi UPS module

    When the Raspberry Pi is connected to a car ignition or the USB port on a TV, you run the risk of data loss with a hard shutdown. The Pi UPS bridges short lapses in the power supply and shuts down your Rasp Pi safely when the power remains off.

  • Slicing and dicing data with regular expressions

    Regular expressions help you filter through the data to find the information you need.

  • Writing and reading man pages

    Man pages provide essential information but may seem cryptic if you're not familiar with their structure. We explain how they're organized so you can get the most out of them.

  • Writing and reading man pages

    Man pages provide essential information but may seem cryptic if you're not familiar with their structure. We explain how they're organized so you can get the most out of them.