Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As written in the title, where should I let the init script write the pid file? are there any standard paths I should choose instead of the /var/run ?

Could /tmp be a good place where to store it or there are drawbacks in that?

share|improve this question
5  
Whats wrong with /var/run? –  arved Jul 27 '12 at 16:27
    
This Stack Overflow question is relevant: stackoverflow.com/q/5173636/1071869 –  Renan Jul 27 '12 at 16:38
    
the only wrong thing with /var/run is that I do not have write access with my user to it.. –  Murko Jul 27 '12 at 17:38
2  
@Murko then you should store the pid file in the user's home directory. –  Renan Jul 27 '12 at 17:44

1 Answer 1

up vote 8 down vote accepted

In short: you could store it anywhere (say, /tmp or /var/tmp), but /var/run is the preferred standard.

/var/run is the Filesystem Hierarchy Standard:

This directory contains system information data describing the system since it was booted. Files under this directory must be cleared (removed or truncated as appropriate) at the beginning of the boot process. Programs may have a subdirectory of /var/run; this is encouraged for programs that use more than one run-time file.[footnote 37]

And a desirable feature is that most distros clean it automatically (unlike /tmp which is not cleaned upon boot in some distros) - this avoid stale pid files:

The normal location for pidfiles is /var/run. Most unices will clean this directory on boot; under Ubuntu this is achieved by /var/run an in-memory filesystem (tmpfs).

It's your choice where to store it, but I would go with the standard.

If you don't have access to /var/run, you should store the pid file in the user's home directory, e.g. ~/.my_app.pid.

share|improve this answer
    
thank you very much, very clear and detailed –  Murko Jul 28 '12 at 7:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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