[CentOS] /var/run/... being deleted :((

Thu Sep 21 12:24:33 UTC 2017
Jonathan Billings <billings at negate.org>

On Sep 21, 2017, at 8:14 AM, hw <hw at gc-24.de> wrote:
> what keeps deleting files and directories under /var/run?  Having them deleted
> is extremely annoying because after a reboot, things are suddenly broken because
> services don´t start.

Assuming that this is a CentOS 7 system, /var/run is just a link to /run, which is a tmpfs filesystem.  No files there survive a reboot.m

If you need directories to be automatically created, you’ll need to use systemd-tmpfiles.  Basically, the packages put files in /usr/lib/tmpfiles.d/, and you’d add your own in /etc/tmpfiles.d/.  

For example, fail2ban has:

$ cat /usr/lib/tmpfiles.d/fail2ban.conf
D /var/run/fail2ban 0755 root root -

Read the ‘tmpfiles.d’ man page for more details.

--
Jonathan Billings <billings at negate.org>