[CentOS] how to prevent files and directories from being deleted?

Thu Oct 5 10:00:15 UTC 2017
Anand Buddhdev <anandb at ripe.net>

On 05/10/2017 11:32, hw wrote:

>> That directory isn't temporary.  The files almost always are, but not
>> the directories.  As I said, whatever it is you're doing, it's wrong. 
>> I wouldn't continue to keep a setup like that as it's not standard
>> practice to keep data in /var/run that isn't temporary.
> 
> Well, what am I supposed to do?  The socket (or what it was) needs to be
> put somewhere, and IIRC, it wasn´t my choice to put it there but is a
> default.  With mariadb, there are some defaults you can´t reasonably
> change because other software expects files where they usually are.  And
> I don´t want to change that, I just want mariadb and lighttpd and other
> things to start on reboots rather than being broken because someone
> decided that files/directories they require are to be deleted on reboots
> before they can start.

I can't believe people are still asking this question after being given
appropriate advice. So let me repeat it, and don't ask again unless
you've read this properly:

1. /var/run is a symlink to /run, which is a tmpfs mounted in RAM.

2. At reboot, /run vanishes, and EVERYTHING that was in it, vanishes
with it.

3. For this reason, systemd ships with a utility called
systemd-tmpfiles, which is run early in the boot process, to create any
appropriate files and directories in /run. Packages that require
directories to be present in /run (for keeping PID files or sockets),
should ship with the appropriate tmpfiles.d snippets to have these
directories created for them on boot.

4. Finally, if you as a sysadmin are using a package from a repo that
isn't CentOS or EPEL, and this package is not following the CentOS
packaging protocol for data in /run, then it is YOUR own responsibility
to fix the package, or create your own tmpfiles.d snippet to create the
required directories.

5. Learn about systemd-tmpfiles by reading the man pages of
"systemd-tmpfiles" and "tmpfiles.d".

This is as clear as crystal. If, despite this instruction, you cannot,
or do not want to work with CentOS as it was intended, then stop whining
about things here.

Regards,
Anand