Bash Scripting Series — Level 4
Bash Scripting Series — Level 4: Checking Running Processes and Finding PIDs Introduction In Level 3, we created a Bash script that validates a directory and generates a compressed backup. We used conditional statements, loops, variables, and exit-status handling to make the script more reliable. In Level 4, we move from filesystem operations to process management . Linux runs many processes simultaneously. These include system services, terminal commands, background jobs, applications, and security tools. Sometimes, you need to determine whether a particular process is running and identify its Process ID (PID). For example, you might want to check whether a monitoring tool is running, verify that a background task started successfully, or locate a process for troubleshooting. In this lesson, we will examine a Bash script that searches for a process by name, displays its PID or PIDs, and reports when no matching process is found. 1. The Original Script Here is the script we will analyz...