Chapter 9. Checking and Managing Running Processes

IN THIS CHAPTER

  • Viewing active processes with ps and top

  • Searching for processes with pgrep

  • Adjusting CPU priority with nice and renice

  • Moving processes to the background (bg) or foreground (fg)

  • Killing and signaling processes with kill and killall

  • Using at and batch to run commands

  • Scheduling commands to run repeatedly with cron

When an executable program starts up, it runs as a process that is under the management of your Linux system's process table. Linux provides all the tools you need to view and change the processes running on your system.

The ps and top commands are great for viewing information on your running processes. There are literally dozens of options to ps and top to help you view process information exactly the way you want to. The pgrep command can further help find the process you want.

There are commands such as nice and renice for raising and lowering processor priority for a process. You can move processes to run in the background (bg command) or back to the foreground (fg command).

Sending signals to a process is a way of changing its behavior or killing it altogether. Using the kill and killall commands, you can send signals to processes by PID or name, respectively. You can also send other signals to processes to do such things as reread configuration files or continue with a stopped process.

To run commands at scheduled times or so they are not tied to your shell session, you can use the at and batch commands. To ...

Get Fedora® Linux® TOOLBOX: 1000+ Commands for Fedora, CentOS, and Red Hat® Power Users 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.