In my log rotate setup, for a specific log file the rotate has been set to 0. But once the size of the file is reached, the old file is rotated to application.log.1
instead of being deleted.
As per the documentation, the file should be deleted when rotate is set to 0. Why is this happening? I must also say that log rotate is configured to run every hour, but our log file reaches the size within 1 hour. So when logrotate runs every hour, it deletes the old application.log.1
, rolls over the current application.log
to application.log.1
and creates a new application.log
file.
The config for the file looks like below:
/var/log/application.log
{
rotate 0
weekly
size 256M
missingok
notifempty
copytruncate
compress
delaycompress
sharedscripts
postrotate
reload rsyslog >/dev/null 2>&1 || true
/usr/sbin/scalyr-agent-2 stop
/usr/sbin/scalyr-agent-2 start
endscript
}