Terminating Processes

Every so often, a program misbehaves. Sometimes it’s due to something you configured incorrectly. Other times it’s because the program has a bug. You’ve probably experienced a stuck program before and figured out a way to kill the task using a graphical task manager. You can manage tasks from the command-line interface as well. All you need is the process ID.

Let’s start a long-running task in the background. In your terminal, execute this command:

 $ ​​sleep​​ ​​9999999​​ ​​&
 [1] 23841

This process is now running. Use the jobs -l command to list the running background jobs and show the process ID in addition to the job ID:

 $ ​​jobs​​ ​​-l
 [1]+ 23841 Running sleep 999999 &

The kill command terminates processes by ...

Get Small, Sharp Software Tools now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.