11

I'm quite new in Linux world, and now I'm trying to understand FHS principles.

In /var/run I found about ten *.pid files like crond.pid which contain just PIDs.

There are more than ten processes running in the system and just ten files.

So what is their purpose and what generated them?

1
  • 3
    See also: What is a .pid file and what does it contain? and What are pid and lock files for?. One should add that this is a simple way of finding a daemon process by name, but not a particularly robust/well-programmed one. Accidental shutdowns may leave orphan pidfiles, upon which a daemon restart fails because "daemon is still running". Auto-cleaning resource (e.g. a server socket on a known port) would seem better nowadays. Sep 13, 2015 at 1:31

1 Answer 1

14

The purpose of these files is to provide an easy means for other processes to communicate with them (e.g. send signals). This only makes sense for long running services, that’s why you find much less such files than processes running.

Usually those files are created by the service they represent, you will find a parameter like --pid-file or so in the invocation.

Depending on the type of init-system you will find files for services in different places.

  • sysv-init: /etc/init.d/
  • upstart: /etc/init/
  • systemd: /etc/systemd/

You must log in to answer this question.

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