Re: question on /var/run
On Wed, Mar 15, 2023 at 09:32:40PM +0300, Reco wrote:
> On Thu, Mar 16, 2023 at 02:20:39AM +0800, coreyh@free.fr wrote:
> > I have put these statement in @reboot crontab for auto startup.
> >
> > @reboot mkdir -p /var/run/xxx && chown -R www-data:www-data /var/run/xxx
>
> I'd use systemd-tmpfiles(8) for that.
> Just because you probably want that directory to exist before your
> webserver starts up and not in the arbitrary point in the future.
>
> Something like this should do it for you:
>
> cat > /etc/tmpfiles.d/xxx.conf << EOF
> d /run/xxx 0755 www-data www-data
> EOF
Or, if this is needed as part of the web server's service, add a
RuntimeDirectory= directive to the web server's unit file.
systemd.exec(5):
Use
RuntimeDirectory= (see below) in order to assign a writable runtime
directory to a service, owned by the dynamic user/group and removed
automatically when the unit is terminated.
Directory Below path for system units
RuntimeDirectory= /run/
In case of RuntimeDirectory= the innermost subdirectories are
removed when the unit is stopped. It is possible to preserve the
specified directories in this case if RuntimeDirectoryPreserve= is
configured to restart or yes (see below).
And so on.
Reply to: