Any folders or files I create in /var/run/ get deleted when restarting the mac

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


Solution 1:

/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.