On Thu, Aug 24, 2023 at 10:49 AM 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
>
>
Not with built-in systemd tools. If it's a periodic (not permanently
running) service, best you can do is script a monthly cronjob that
automatically edits the StandardOutput line in your .service unit.


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

It's called /etc/logrotate.conf and it's what everyone else does. It's what
Debian/Ubuntu itself uses for /var/log/apt*.log and such.

-- 
Mantas Mikulėnas

Reply via email to