I'm trying to rotate logs daily EXCEPT when my logfile is over 500M then it should be rotated asap, so I've copied my /etc/cron.daily/logrotate
into /etc/cron.hourly
and my config file looks like this :
compress
missingok
/path/to/my/logfile.log
{
daily
maxsize 500M
ifempty
copytruncate
olddir /path/to/my/archived/logs/
dateext
}
the dateext
is here to make sure the log rotation works the same way as the old log rotation tool (several dedicated custom scripts).
As it is, when logfile.log
is over 500M a rotation happens, which create logfile.log.YYYYMMDD.gz
, but if logfile.log
reaches again 500M the same day (which is more than likely to happen) then I have an issue since logfile.log.YYYYMMDD.gz
already exists.
So my quesion is, Is there a way to append the log content into an already existing rotated log file, in order to have only one archived log per day ?