How to assign a particular PID to a process?

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux All versions

Issue

  • Is there any way to assign a PID for a particular process? After restarting the process, the PID changes and it breaks the PID monitoring by nagios. How to workaround this?

Resolution

There is no way to permanently assign a particular PID to a process or service. The PIDs are sequentially assigned and when a lower PID is freed, the next starting process will take up that PID. Thus PIDs are being reused.

For the use case mentioned in issue section, change the nagios configuration to check the PID of the service from /var/run/service.pid file, rather than hard-coding the PID number into the configuration file.

For example, for monitoring the cupsd process,   get the PID of cupsd from the file /var/run/cupsd.pid.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.