Another option for log rotation on Linux machines is to use logrotate with copytruncate
parameter.
logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.
logrotate reads everything about the log files it should be handling from the series of configuration files specified on the command line. Each configuration file can set global options (local definitions override global ones, and later definitions override earlier ones) and specify logfiles to rotate. A simple configuration file looks like this:
copytruncate
Truncate the original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one. It can be used when some program cannot be told to close its logfile and thus might continue writing (appending) to the previous log file forever. Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the create option will have no effect, as the old log file stays in place.
Add this entry to logrotate configuration file
/var/log/spring.log {
daily
copytruncate
rotate 3
dateext
notifempty
}
What's next? See How to make log-rotate change take effect?
logrotate
uses crontab
to work. It's scheduled work, not a daemon, so no need to reload its configuration.