I'm setting up monit and want to monitor a given python application. Monit does this by looking at the .pid files for processes, but I don't know where this would be.
I also tried creating my own simple executable and running it- here too I can't figure out where the .pid file is created.
And do all processes have a .pid file?
Best Answer
You'll usually find the PID files for daemonized processes in
/var/run/
on Redhat/CentOS-style systems.Short of that, you can always look in the process init script. For instance, the SSH daemon is started with the script in
/etc/init.d/sshd
. Sometimes the PID will be defined there (search for pid, PID, PIDFILE, PID_FILE, etc.).However, most other daemons on RHEL-style systems source the
/etc/init.d/functions
script for some common features.For anything that sources
/etc/init.d/functions
, the PID will live in/var/run/*.pid
.For custom applications, the PID will be defined in a wrapper script (hopefully). Most developers I know follow the same convention as the daemons above, though.
If you do encounter something without a PID file, remember that Monit can monitor on a process string patern as well.