On Thu, Aug 24, 2023 at 10:49 AM Cecil Westerhof <cldwesterhof@xxxxxxxxx> wrote:
In a service file I can use:StandardOutput=append:/var/log/root/aptCacheUsage.logbut I want to use something like:StandardOutput=append:/var/log/root/aptCacheUsage_$(date +%%Y-%%m).logDid does not work, because this puts it in:/var/log/root/aptCacheUsage_$(date +%Y-%m).logIs there a way I can put it in:/var/log/root/aptCacheUsage_2023-08.logwhile 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.logand 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