Logrotate configuration

If none of the more specific forums is the right place to ask

Logrotate configuration

Postby PsySc0rpi0n » 2021-02-20 20:38

Hello,
I have set the following configuration for logrotate in /etc/logrotate.d/my-app

Code: Select all
/path/to/my-app/debug.log {
    rotate 3
    maxsize 100M
    dateext
    dateformat -%d-%m-%Y
    maxage 31
}


But the result is not being what I expected. What I want is that debug.log file don't exceed 100MB and when 100MB are reached, a new debug.log file is created, and when there are 3 old debug files (100MB each), the older one gets deleted to be able to save a newer one. Instead, this is what I am getting:

Code: Select all
0 Feb 20 00:00 debug.log
447M Feb 15 08:47 debug.log-14-02-2021
868M Feb 18 21:49 debug.log-16-02-2021
418M Feb 20 21:23 debug.log-20-02-2021


So, is this wrong for what I want to do or what am I missing?
User avatar
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: Logrotate configuration

Postby peter_irich » 2021-02-21 08:10

Perhaps, this log grows very quickly and achieves value from maxsize early than cron will be run.

Peter.
peter_irich
 
Posts: 1308
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: Logrotate configuration

Postby PsySc0rpi0n » 2021-02-24 19:24

peter_irich wrote:Perhaps, this log grows very quickly and achieves value from maxsize early than cron will be run.

Peter.


Ok, good point. Will check that,
But apparently, the config I have should perform what I describe, right?
User avatar
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: Logrotate configuration

Postby peter_irich » 2021-02-25 17:31

Yes, I think this config is right.
But log is not must grow such quickly. It is need to find which program or daemon writes to it.
peter_irich
 
Posts: 1308
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation

Re: Logrotate configuration

Postby drasar » 2021-03-02 22:32

I guess that you may shorten logrotate run frequency. Usually logrotate is configured to be run by cron daily. And if your app logs hundreds MB of logs every day, then logrotate doesn't have a chance to rotate them properly on every 100 MB in size.

So try to reconfigure the logrotate default run interval e.g. for one hour.

You won't probably achieve exactly 100 MB maximally for each log file, but at least you will be much closer than now. But still it depends how much are the logs spread in time...
drasar
 
Posts: 12
Joined: 2020-01-11 19:50


Return to General Questions

Who is online

Users browsing this forum: No registered users and 13 guests

fashionable