I have the following configurations in /etc/logrotate.d/rsyslog
:
/var/log/syslog
{
rotate 7
size 1G
missingok
notifempty
delaycompress
compress
postrotate
invoke-rc.d rsyslog rotate >/dev/null
endscript
}
From what I understand, I've set it up so if /var/log/syslog
reaches 1G
in size, it will rotate itself. Also, the system will hold 7 rotations.
In testing, I did this:
cat /dev/null > /var/log/syslog
base64 /dev/urandom | head -c 999999999 > /var/log/syslog
logger -s "hello"
Then I did this:
ls -las /var/log/syslog*
976568 -rw-r----- 1 syslog adm 1000000072 Jul 28 19:11 /var/log/syslog
It's showing the file size as 1.000000728 GB
shouldn't it have rotated itself?
When applying the configurations, I did systemctl restart rsyslog
Logrotate uses traditional units rather than SI units for K, M, G, etc. This means literally, quoting from the source code:
1024 * 1024 * 1024
, or 1073741824 bytes.