I have a service managed by systemd that has the following systemd config telling systemd to write the logs to a file directly (no syslog or anything)
I have a logrotate rule
What's happening is that the logs are being rotated but the service is still writing to the old rotated file and the new log file stays empty.
I have a similar working setup where the service instead writes to syslog. That one works fine because the logrotate config has
invoke-rc.d rsyslog rotate > /dev/null
, which notifies syslog that its log has been rotated.
The issue is that in my problematic case the log is going directly to the file so I don't know if (or which one) i need to send a similar signal to systemd or to the actual service process.
I found the
copytruncate option in logrotate which i'm pretty sure will fix my problem but i'm getting the feeling that this is not the ideal way to do it, otherwise
copytruncate would be the default behaviour of logrotate.
How do I solve this problem? do i need to send some signal to systemd? do i need to send some signal to the service process? do i have to use
copytruncate in logrotate instead?
If it matters, the service is a java process using logback to write to stdout