Re: Logging maintenance question

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

 



Gene Heskett wrote:
> I just discovered that some custom scripts I wrote a year or so,
> seem to have gone on the milling list, and that both the
> fetchmail.log and the procmail.log were approaching a gigabyte in
> size.

Ouch. :)

> So I cobbled up this:
> ======
> # Logrotate file for fetchmail.log and procmail.log
> 
> /var/log/fetchmail.log {
> 	missingok
> 	compress
> 	notifempty
> 	weekly
> 	rotate 5
> 	create 0600 gene gene
> }
> /var/log/procmail.log {
>       missingok
>       compress
>       notifempty
>       weekly
>       rotate 5
>       create 0600 gene gene
> }
> ==========
> and put it in /etc/logrotate.d with the same perms as most of them
> there.

I use logrotate to rotate fetchmail, mpd, and procmail logs monthly.
I keep the logs in ~/var/logs and logrotate as myself (not required,
but nice IMO).

$ cat ~/.logrotate/conf
monthly
rotate 12
create
dateext
compress

/home/tmz/var/log/fetchmail {
    missingok
    notifempty
}

/home/tmz/var/log/mpd {
    missingok
    notifempty
    postrotate
        ~/bin/mpd-restart || true
    endscript
}

/home/tmz/var/log/procmail {
    missingok
    notifempty
}

Then I have a script that runs something like this via cron:

/usr/sbin/logrotate -s ~/.logrotate/status ~/.logrotate/conf

I don't run fetchmail as a daemon, so I don't have logrotate handle
restarting or signalling fetchmail when it rotates the logs.  You'll
want to handle that if you're running fetchmail as a daemon.  The mpd
entry above and others in /etc/logrotate.d might be useful to you in
setting that up.

> But, executing "logrotate -v /etc/logrotate.conf"  returns instantly
> doing nothing to the old logs.  The generated listing of course is
> detailed and includes this:
> ======
> rotating pattern: /var/log/fetchmail.log  weekly (5 rotations)
> empty log files are not rotated, old logs are removed
> considering log /var/log/fetchmail.log
> log does not need rotating
> 
> rotating pattern: /var/log/procmail.log  weekly (5 rotations)
> empty log files are not rotated, old logs are removed
> considering log /var/log/procmail.log
> log does not need rotating

Take a look at the -f option in logrotate(1):

    -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 logrotate, or if old log files have been
        removed by hand, as the new files will be created, and logging
        will continue correctly.

You only need that the first time after creating the new rules (and
only if you can't wait for them to be rotated on schedule).

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The more corrupt the state, the more numerous the laws.
    -- Tacitus, Roman senator and historian (A.D. c.56-c.115)

Attachment: pgpWpiHBDpN4x.pgp
Description: PGP signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux