How do I find the PID file for a process given the PID number?

Alasdair asked:

I’m trying to use Monit to monitor and send email alerts about a process when it stops running, but I need the location of the PID file for that process. I can find the PID number using the htop or ps commands and I thought it would be pretty straightforward to find the PID file from there, but after searching Google and StackExchange I’ve found nothing to answer my question.

I’m aware of this thread: How to find the .pid file for a given process but found it unhelpful. The answer given just mentioned the usual location of PID files, and it was for Redhat/CentOS-style systems. I’m using Ubuntu, and hoping for a more concrete answer. Isn’t there a command that returns the path to the PID file given the PID number?

Thank you!

My answer:


There is no such thing. A process may not even have a PID file. It is not required for a process to create one. If a process creates a PID file it may do so anywhere that it has permission to write to. To know where a program writes its PID file you must check its configuration.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.