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: pgpItG10ixj2Q.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]     [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