On Do, 24.08.23 09:48, Cecil Westerhof (cldwester...@gmail.com) wrote:

> In a service file I can use:
>     StandardOutput=append:/var/log/root/aptCacheUsage.log
>
> but I want to use something like:
>     StandardOutput=append:/var/log/root/aptCacheUsage_$(date +%%Y-%%m).log
>
> Did does not work, because this puts it in:
>     /var/log/root/aptCacheUsage_$(date +%Y-%m).log
>
> Is there a way I can put it in:
>     /var/log/root/aptCacheUsage_2023-08.log
>
> while it would automatically next month go into:
>    /var/log/root/aptCacheUsage_2023-09.log
>
> I could of-course put it into:
>     /var/log/root/aptCacheUsage.log
>
> and at the beginning of the month move it if it exists with a timed
> service, but I really would not like that kind of solution.

We do not support this. systemd supports evaluating some specifiers,
but time/date is not one of them, in particular as we resolve
specifiers at parse time of the unit only, not afterwards. or in other
words: we'd resolve the specifiers early at boot, and that doesn't
look like what you want.

Also, for long-running services this wouldn#t work anyway, as we can't
rotate files like that, because we cannot externally close the current
stdout of a process and replace it with a new file.

hence, what you are trying to do is not supported, and is unlikely to
ever be supported for multiple reasons.

sorry!

Lennart

--
Lennart Poettering, Berlin

Reply via email to