LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Rotate logfiles multiple times a day (https://www.linuxquestions.org/questions/linux-newbie-8/rotate-logfiles-multiple-times-a-day-868256/)

jonaskellens 03-13-2011 04:15 AM

Rotate logfiles multiple times a day
 
Hello,

how can I rotate logfiles multiple times a day ?

I notice that the configuration for the logrotate-command is hourly, daily, weekly,...

I notice that I can create a cron job where I specify the different times the log rotation need to be done :
15 0,8,12,17 * * *

But how do I combine these two ?

repo 03-13-2011 05:08 AM

To force the logs to be rotated, you can use
Code:

logrotate -f -s -d /etc/logrotate.conf
Kind regards

jonaskellens 03-13-2011 05:17 AM

Quote:

Originally Posted by repo (Post 4288903)
To force the logs to be rotated, you can use
Code:

logrotate -f -s -d /etc/logrotate.conf
Kind regards

And so it does not matter what is defined in logrotate.conf ?? Whether daily or weekly is set in logrotate.conf does not matter when I use a crontab ?

repo 03-13-2011 05:20 AM

Quote:

And so it does not matter what is defined in logrotate.conf ?? Whether daily or weekly is set in logrotate.conf does not matter when I use a crontab ?
No, it will rotate the logs specified in the logrotate.conf file.

Quote:

-f, --force
Tells logrotate to force the rotation, even if it doesn't think this is necessary. Sometimes this is useful after adding new entries to a logrotate config file, or
if old log files have been removed by hand, as the new files will be created, and logging will continue correctly.
Kind regards

jonaskellens 03-13-2011 05:27 AM

Will the "rotate daily" or "rotate weekly" command in logrotate.conf be executed also ?!

So in other words, will I have at the end of the week an extra rotate ?

repo 03-13-2011 05:37 AM

Quote:

So in other words, will I have at the end of the week an extra rotate ?
Only if the logfile meets the values, set in logrotate.conf or in the logrotat.d directory,
like size etc.

Kind regards

jonaskellens 03-13-2011 02:16 PM

Quote:

Originally Posted by repo (Post 4288928)
Only if the logfile meets the values, set in logrotate.conf or in the logrotat.d directory,
like size etc.

So if the value "rotate weekly" is set in logrotate.conf, then at the end of the week I will have an extra rotation ?

Can I omit the "rotate" value ?!

repo 03-13-2011 02:25 PM

Quote:

So if the value "rotate weekly" is set in logrotate.conf, then at the end of the week I will have an extra rotation ?
If it meets the values, like size etc
It will only rotade if the size is > then x,or if the log is older then x
But since you are going to rotate several times a day, the weekly and monthly rotation doesn't matter anymore.


Kind regards


All times are GMT -5. The time now is 08:58 AM.