Re: Logrotate - daily log files for a month

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Message: 11
Date: Thu, 23 Aug 2007 16:20:34 +0100
From: John Horne <john.horne@xxxxxxxxxxxxxx>
Subject: Re: Logrotate - daily log files for a month
To: For users of Fedora <fedora-list@xxxxxxxxxx>
Message-ID: <1187882434.2814.13.camel@xxxxxxxxxxxxxxxxxx>
Content-Type: text/plain

On Fri, 2007-08-24 at 00:34 +0930, Tim wrote:
> On Thu, 2007-08-23 at 15:27 +0100, John Horne wrote:
> > this does not account for month's of 31 days, or February with 28/29
> > days
> > I'd guess that you'd have to do what banks do: Do your activities on
> the first of the month.  If you do it close after midnight, you keep the
> last month's work, and start a new month's, hoping that you want nothing
> in the last few moments to be part of this month's data.
>
Not sure how this is going to help. How to do I configure this with
logrotate?

As far as I am aware logrotate runs daily, and since we want daily log
files I don't see how logrotate is going to know what a 'month' is on a
daily basis. I agree it knows what a 'month' is for monthly log file
rotation, simply because the month (name or number) changes.

What is needed it seems is logrotate to know that the month has changed,
but to keep to the daily log file rotation regardless of what 'rotate'
value is given. That way I get 31 log files for a 31-day month, 30 log
files for a 30-day month and so on.

John.

You will need a number of script files and logrotate files.
Then you set up a crontab (probably best as root) which checks at say 23:45 on the last day of each month, 28/29th, or 30th or 31st day depending on the month value, in separate lines, and each calls a script file which *substitutes* a new logrotate.conf file for the old one. Thus every month the logrorate file which is used corresponds to the number of required logging days.

Crontab will have 12 lines and will only need changing every 4th year for February.

The crontab will look like:

45 23 5 31 * /usr/local/sbin/logrotate-30days # May 31 set logrotate for 30 days for June
45 23 6 30 * /usr/local/sbin/logrorate-31days   # June 30, set to 31
45 23 7 31 * /usr/local/sbin/logrotate-31days
45 23 8 31 * /usr/local/sbin/logrotate-30days

Or you could run them at 03 00 x 1 *   that is, early on the first day.

A logrotate-xxdays file would just 'cp -f /etc/logrotatexx.conf /etc/logrotate.conf'


It would also be possible to run a script to 'sed /s/30/31' against the logrotate.conf but that seems to be overkill and hard for maintain.

It might also be possible to have a variable in a logrotate file (as in 'rotate $ROTATE_TIMES') but I did not bother to check that out. That also would be harder to maintain as it is more obscure than just changing the file.

For testing, I have things trigger every minute, but each called script ends with a line '/usr/bin/aplay /usr/share/sounds/KDE_Beep_something.wav so you hear a different sound every minute, which tells you that a different test/script was run.



             R. Geoffrey Newbury			
           Barrister and Solicitor
      Suite 106, 150 Lakeshore Road West
         Mississauga, Ontario, L5H 3R2

        o905-271-9600 f905-271-1638
          newbury@xxxxxxxxxxxx

       Helping with the HTTP issue
<a href="http://www.w3.org/Protocols/";>HTTP</a>

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux