My /etc/logrotate.conf :
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# use date as a suffix of the rotated file
dateext
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
My Logs to be rotated /etc/logrotate.d/apc_rtbinfo.conf
/mnt/log/frengo/apc_rtbinfo.log {
daily
missingok
notifempty
size 2000M
compress
delaycompress
sharedscripts
copytruncate
rotate 3
}
Output for logrotate :
logrotate -v /etc/logrotate.d/apc_rtbinfo.conf
reading config file /etc/logrotate.d/apc_rtbinfo.conf
reading config info for /mnt/log/frengo/apc_rtbinfo.log
Handling 1 logs
rotating pattern: /mnt/log/frengo/apc_rtbinfo.log 2097152000 bytes (3 rotations)
empty log files are not rotated, old logs are removed
considering log /mnt/log/frengo/apc_rtbinfo.log
log does not need rotating
My rotated Logs size :
# du -sh /mnt/log/frengo/apc_rtbinfo.log*
0 /mnt/log/frengo/apc_rtbinfo.log
4.7G /mnt/log/frengo/apc_rtbinfo.log.1
80M /mnt/log/frengo/apc_rtbinfo.log.2
0 /mnt/log/frengo/apc_rtbinfo.log-20151222
679M /mnt/log/frengo/apc_rtbinfo.log-20151225.gz
681M /mnt/log/frengo/apc_rtbinfo.log-20151226.gz
691M /mnt/log/frengo/apc_rtbinfo.log-20151227.gz
0 /mnt/log/frengo/apc_rtbinfo.log-20151228
70M /mnt/log/frengo/apc_rtbinfo.log.2.gz
80M /mnt/log/frengo/apc_rtbinfo.log.3
80M /mnt/log/frengo/apc_rtbinfo.log.4
Log rotate output says "log does not need rotating" but I have mentioned "size 2000M" ie Log file is rotated if it grow bigger than 2000M then how come "/mnt/log/frengo/apc_rtbinfo.log.1" is 4.7 GB
dateext
in the config file. It's possible something else is rotating them as well, and that something else created the .1 file.