LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Logrotate - did I get it right? (https://www.linuxquestions.org/questions/linux-general-1/logrotate-did-i-get-it-right-456401/)

Swakoo 06-19-2006 09:36 PM

Logrotate - did I get it right?
 
My logrotate for maillog is as such

Quote:

/usr/local/psa/var/log/maillog.processed {
daily
missingok
rotate 7
size 50M
compress
nocreate
}
My intention is to have the log rotate and have an archive of 7days at anyone time. Also, each log file should be no more than 50MB before compress, so if in one day the log hits 100MB, I should have 2 logs per day and by the end of 7 days, I should have 14logs.

Is my above logrotate settings correctly set to achieve what I need? because currently my latest log file is 37MB and it didn't get compress, and the last log entry was 4am before it started on a new log...

Questions:

1) my log was not compress after it started a new log. Is it because it didn't reach 50MB?

2) I understand the service/log restarts at 4am each day (hence the new log). Is it possible to control when this restart happens?

3) Will the above settings be able to achieve my intended objectives? 7 days log, each file no > 50MB, can have multiple logfiles each day (<50MB)

Many thanks!

unSpawn 06-20-2006 05:14 AM

1) my log was not compress after it started a new log. Is it because it didn't reach 50MB?
About compression: logrotate usually is set up as a cronjob, so if there's any errors they should be in root's email. About size: AFAIK you should read "rotate this log daily OR now if size matches threshold", which comes in handy when you run it several times a day. Note that if size isn't triggered and the run is set to daily it may produce less than fourteen logs. BTW, you don't need to run all of logrotate: you can force a specific job to run (say in a separate cronjob) with "logrotate /etc/logrotate.d/nameofjob".


2) I understand the service/log restarts at 4am each day (hence the new log). Is it possible to control when this restart happens?
Restarts related to logrotate runs are usually placed in "postrotate" statements. Check your logrotate.conf, /etc/logrotate.d/ files or other cronjobs.


3) Will the above settings be able to achieve my intended objectives? 7 days log, each file no > 50MB, can have multiple logfiles each day (<50MB) / so if in one day the log hits 100MB, I should have 2 logs per day and by the end of 7 days, I should have 14logs.
No, it don't work that way. You specified seven logs to be archived. If you for instance run logrotate twice a day and want fourteen logs, you'll have to specifiy "rotate 14".


All times are GMT -5. The time now is 02:52 PM.