Silly logrotate question
Ok, I have Googled this and either I am not asking the right way or I just
can't see what's in front of me (sorry)... We have log files called app.2011-10-119.log (with the date changing every day). The log is created by the application each day at midnight. I have logrotate set to rotate files ending in .log at 4am, with copytruncate on by default. If I list the files I see all the old app.2011-10-<X>.log files with a 0 file size. If I turn off copytruncate, the current days log file will be removed everyday at 4am. How can I satisfy both the need to remove yesterday's log file while keeping the current day? Here is the logrotate file: /var/log/app/*.log { daily rotate 10 compress missingok notifempty create 0644 user user } I added notifempty to keep the old empty log files from being compressed... Thanks, John John Kennedy _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos |
Silly logrotate question
On 10/19/2011 05:14 AM, John Kennedy wrote:
> How can I satisfy both the need to remove yesterday's log file while keeping > the current day? Hi, I perfectly understand your problem. "copytruncate" is not your friend here so, taking "copytruncate" out of the picture, I really don't see a quick fix as logrotate doesn't provide a facility to work on files OLDER than X days. If there was such an option, you could tell it to rotate all the *.log files from the previous day (move them & compress, not copy them) without affecting your current day log. Possible workarounds: 1) Modify your app if you can so that it stops creating new files daily. Something like app.log. Use the "copytruncate" & "dateext" (along with your other options) in the logrotate configuration so that every day the file is COPIED & COMPRESSED to app.log.20111119.gz. That way your file is truncated everyday and you'll have nicely compressed historical archives (with the date appended) which you can keep for X days depending on your "rotate X" value. 2) get creative with the "prerotate" and "postrate" options of logrotate. 3) if your app is smart enough to create a log daily perhaps you could tell it to compress the previous file and get rid of logrotate for that. HTH, Jorge _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos |
Silly logrotate question
Hi,
I’m probably missing something here... On Wednesday, October 19, 2011 at 6:14 PM, John Kennedy wrote: > Ok, I have Googled this and either I am not asking the right way or I just > can't see what's in front of me (sorry)... > > We have log files called app.2011-10-119.log (with the date changing every > day). The log is created by the application each day at midnight. > I have logrotate set to rotate files ending in .log at 4am, with > copytruncate on by default. > If I list the files I see all the old app.2011-10-<X>.log files with a 0 > file size. > If I turn off copytruncate, the current days log file will be removed > everyday at 4am. You mean current day’s? And by “current day’s”, you mean the logs after midnight up to 4 a.m.? > How can I satisfy both the need to remove yesterday's log file while keeping > the current day? Why not run your logrotate just right after midnight? (Instead of at 4 a.m.) > Here is the logrotate file: > > /var/log/app/*.log { > daily > rotate 10 > compress > missingok > notifempty > create 0644 user user > } > > I added notifempty to keep the old empty log files from being compressed... Or, forget about logrotate and simply run a script right after midnight with something like the ff: rm app.`date --date="yesterday" +%Y-%m-%d`.log > Thanks, > John > > John Kennedy > HTH, -- - Edo - mailto:ml2edwin@gmail.com “Do not hold back good from those to whom it is owing, when it happens to be in the power of your hand to do [it].”—Proverbs 3:27 _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos |
| All times are GMT. The time now is 11:06 AM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.