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 ...
Get Troubleshooting CentOS 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.