Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Logrotate configuration

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Logrotate configuration

#1 Post by PsySc0rpi0n »

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?

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Logrotate configuration

#2 Post by peter_irich »

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

Peter.

User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: Logrotate configuration

#3 Post by PsySc0rpi0n »

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?

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Logrotate configuration

#4 Post by peter_irich »

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.

drasar
Posts: 12
Joined: 2020-01-11 19:50

Re: Logrotate configuration

#5 Post by drasar »

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...

Post Reply