4

Any added files or folders in /var/run they are deleted when I restart my machine. Why is this happening? What should I do to ensure these files are not deleted (or are recreated) and how would I go about doing this?

Any help appreciated

simpleengine
  • 395
  • 1
  • 3
  • 6

1 Answers1

7

/var/run is mounted as tmpfs. That means it's totally empty when your machine boots and it's meant to be like this to prevent stuff like daemons not starting because of a left-over PID-file. Startup scripts usually create the directories they need in there before using them. If you want to store a PID-file either put it in /var/run directly or create a directory before creating the PID-file. This is no place to store data that needs to remain there across reboots.

lsmooth
  • 1,521
  • 1
  • 9
  • 17
  • Hi Ismooth, thanks for your answer. I am using it to store a PID-file, but the directory I create within the /var/run directory is deleted whenever I restart my mac. Is there a way of ensuring this folder is not removed or is recreated on startup? – simpleengine Feb 21 '13 at 01:00
  • 1
    @simpleengine Either don't create a directory at all, or re-create it at startup. – Michael Hampton Feb 21 '13 at 01:37
  • I'm not familiar with Mac, but there must be some documentatinon on how to handle such a situation. Or trawl through the configuration of other daemons to pilfer the way of doing it from there. – vonbrand Feb 21 '13 at 03:37