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

Re: Logging of mail events from Postfix to syslog and rotation of the mail logs



On Wed, Feb 08, 2006 at 09:45:33AM -0600, Anthony Simonelli wrote:
> On Monday 30 January 2006 12:03 am, Simo Kauppi wrote:
> > >
> > > If I write my own in /etc/logrotate.d similar to exim's or another
> > > service's settings, will this override the current behavior now?
> >
> > Hi,
> >
> > Yes, I believe so. The global option is 'weekly' and files in the
> > /etc/logrotate.d directory override that. I.e. if postifx doesn't have
> > logrotation defined anywhere else, you can just create a file in
> > logrotate.d and that should do the trick.
> >
> > Simo
> 
> I created that script, called it postfix and tested it out and it runs but not 
> the way I wanted it to.  The following is the script that I used:
> 
> /var/log/mail.* {
>         daily
>         missingok
>         rotate 28
>         compress
>         delaycompress
>         notifempty
>         create 640 root adm
>         sharedscripts
> }
> 
> It works but not the way I wan it to.  Here is a list of the mail logs after 
> three days:
> 
> user@foo:~$ ls -lh /var/log/mail.*
> -rw-r-----  1 root adm    0 2006-02-07 03:30 /var/log/mail.err
> -rw-r-----  1 root adm   88 2006-02-06 15:40 /var/log/mail.err.1
> -rw-r-----  1 root adm    0 2006-02-02 08:30 /var/log/mail.info
> -rw-r-----  1 root adm 1.3M 2006-02-08 09:13 /var/log/mail.log
> -rw-r-----  1 root adm    0 2006-02-08 03:30 /var/log/mail.log.1
> -rw-r-----  1 root adm 4.9M 2006-02-08 03:30 /var/log/mail.log.1.1
> -rw-r-----  1 root adm 477K 2006-02-08 03:30 /var/log/mail.log.2.gz
> -rw-r-----  1 root adm  23K 2006-02-08 09:11 /var/log/mail.warn
> -rw-r-----  1 root adm    0 2006-02-08 03:30 /var/log/mail.warn.1
> -rw-r-----  1 root adm  52K 2006-02-08 03:25 /var/log/mail.warn.1.1
> -rw-r-----  1 root adm 7.5K 2006-02-08 03:30 /var/log/mail.warn.2.gz
> 
> Notice that it put a .1 at the end of a log already with a .1 and the 
> original .1 is 0 bytes in size.  I don't know why this is happening but I 
> need it to be sequential like the following:
> 
> mail.log
> mail.log.0
> mail.log.1.gz
> mail.log.2.gz
> .... etc.
> 
> Does anyone know how to do this?

Hi,

Loose the '*'. Otherwise it will consider already rotated logs as log
files to be rotated. I.e after first day you have mail.log and
mail.log.1 and they are both considered as log files.

You can put a separate entry for each log file into the same file.

Something like:
daily
missingok
rotate 28
compress

/var/log/mail.log {
}

/var/log/mail.info {
}

So first you put all the global options which are the same for each
logfile and then a seaprate section for each file. You can put certain
options to each file section and they are only used for that file.

BTW, option
start 0
should start counting from zero instead from one, which should result in
mail.log
mail.log.0
mail.log.1.gz
and so on.

BTW2, option notifempty means that if the size of the file is zero, it is
not rotated. The default would be to rotate also the zero size files.

HTH,
Simo
-- 
:r ~/.signature

Attachment: signature.asc
Description: Digital signature


Reply to: