Question

I have been using logrotation for quite some time recently I made some configuration changes in it.

Earlier my logrotation used to work upon weekly basis and rotated logs automatically now I have configured it to rotate logs based upon size but now it has stopped working if I use the command logrotate -f 00-rsyslog then it works. I don't know why its not working Here is the 00-rsyslog:

 /rsyslog/log/*/*/*.log
{
        size 1000k
        rotate 500
        missingok
        notifempty
        delaycompress
        compress
        create 640 root root
        sharedscripts
        postrotate
                reload rsyslog >/dev/null 2>&1 || true
        endscript
}

I get around 50 MB of logs everyday on my server. Please Help.

Was it helpful?

Solution

By default, ubuntu calls logrotate once a day.

see the script /etc/cron.daily/logrotate

So when it runs it'll see that the log file is likely > 1000K and rotate it as requested. It'll rotate it once only resulting in your large rotated logs of 50MB.

What you need to do is schedule logrotate to happen more often. e.g. every 10 minutes or more. It really depends how quickly your log files grow.

e.g. Run it every 10 minutes

*/10 * * * * /usr/sbin/logrotate /etc/logrotate.conf >/dev/null 2>&1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top