0

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!

1
  • 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. Mar 10, 2021 at 23:43

1 Answer 1

4

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .