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!

  • The thread you mention is very helpful, because it tells you that processes don't generally have PID files. Also, it mentions /var/run, which is now outdated according to the newest Linux Filesystem Hierarchy Standard (don't forget the thread is 8-9 years old), and replaced by /run. – berndbausch Mar 10 at 23:43

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.