Monitoring Processes in Linux with the ps Command: checking web server Apache processes information

0saves

In the vast toolbox of Linux system monitoring utilities, the `ps` command stands out for its direct approach to tracking what’s happening on your server or desktop. Whether you’re a system administrator, a developer, or simply a curious user, knowing how to leverage `ps` can provide you with insights into the processes running under the hood of your Linux machine.

Why we use `ps` utility?

The `ps` command is versatile and powerful, offering a snapshot of currently running processes. It’s particularly handy when you need to verify whether a specific service, like the Apache web server, is running and how it’s behaving in terms of resource consumption.

Example Use Case: Checking Apache Processes

Httpd or Apache web server is a widely used web server software, is essential for serving web pages. If you’re managing a website or a web application, you might often need to check if Apache is running smoothly. Here’s how you can do that with `ps`:

ps auxwww | head -n 1; ps auxwww | grep httpd | grep -v grep

This command sequence is broken down as follows:

  • `ps auxwww`: Lists all running processes with a detailed output.
  • `head -n 1`: Displays the column headers.
  • `grep httpd`: Filters the list to show only Apache (`httpd`) processes.
  • `grep -v grep`: Excludes the `grep` command itself from the results.

Output Explained:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 21215 0.0 0.1 524056 30560 ? Ss 16:59 0:00 /usr/sbin/httpd -DFOREGROUND
apache 21216 0.0 0.0 308392 14032 ? S 16:59 0:00 /usr/sbin/httpd -DFOREGROUND

  • USER: The username of the process owner.
  • PID: Process ID.
  • %CPU and %MEM: CPU and memory usage.
  • VSZ and RSS: Virtual and physical memory sizes.
  • TTY: Terminal type.
  • STAT: Process status.
  • START: Start time of the process.
  • TIME: Cumulative CPU time.
  • COMMAND: Command line that started the process.

Going Further:

To explore more options and details about the `ps` command, consulting the manual page is always a good idea. Simply type:

man ps

This command brings up the manual page for `ps`, providing comprehensive information on its usage, options, and examples to try out.

Conclusion:

Understanding and utilizing the `ps` command can significantly enhance your ability to monitor and manage processes on your Linux system. It’s a fundamental skill for troubleshooting and ensuring that essential services like Apache are running as expected.