Book Image

Troubleshooting CentOS

By : Jonathan Hobson
Book Image

Troubleshooting CentOS

By: Jonathan Hobson

Overview of this book

Table of Contents (17 chapters)
Troubleshooting CentOS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Discovering process IDs with pgrep and systemctl


Rather than using ps, another way of discovering a specific process ID is to use the pgrep command like this:

# pgrep <servicename>

In most cases, the use of this command will reveal the process ID or PID. However, by using this approach, it is also possible that the output will provide more than one value. So remember, if an application (such as httpd or ssh) provides one or more process IDs, you can safely assume that the lowest number (which represents the first PID generated by the system) is the most important. This value is known as the PPID or parent process ID.

On the other hand, a more succinct method could be based on taking advantage of systemd by using the following command:

# systemctl status <service_name>.service

The output of the preceding command will look similar to the following sample, and as we can see, the main PID for Apache is 2413:

httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd...