I have a service which insists on keeping it's log files in terrible locations. After all efforts to change where it keeps them failed, my next idea was to create hardlinks to those files somewhere cleaner. This led me to a concern:
If I configure logrotate to manage these log files, will it work as intended (rotate logs, keep my links working)? Or will logrotate accidentally break the links, and leave the logs accumulating in their native locations but not in my central one?
I believe I can configure logrotate to re-create the hard links after a rotation if necessary. But, is it necessary?
Best Answer
To answer your question, it kind of depends on what kind of rotating you do. For instance, the following progression will happen:
Copy-and-truncate method:
This leaves the logfile backups in the old location.
The fix to this is fairly simple: configure logrotate to rotate the logs in the new location. The old one will still have the growing file, but it'll only be the one.
Copy-and-create method:
This method is most problematic, and you'll need some post-rotate magic to clean up after it.