logrotate script for Postfix

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

logrotate script for Postfix

Fourhundred Thecat
Hello,

I am using Postfix on Debian. I have noticed that my mail logs are not
being rotated.

I see that there is no rule in my /etc/logrotate.d/ for rotating mail logs.

Which program's responsibility is it?

Is it supposed to come with Postfix, or is this the responsibility of
the operating system, or rsyslog ?

I can probably reuse some of the other rules to create new rule for
mail.log, but I am not sure about the postrotate command. Should postfix
be reloaded after logs are rotated, or rsysylog reloaded?

This is an example rule form other logs:

        postrotate
                invoke-rc.d rsyslog rotate > /dev/null
        endscript
Reply | Threaded
Open this post in threaded view
|

Re: logrotate script for Postfix

Nick-5
On 2020-05-09 15:28 BST, Fourhundred Thecat wrote:
> I am using Postfix on Debian. I have noticed that my mail logs are not
> being rotated.
>
> I see that there is no rule in my /etc/logrotate.d/ for rotating mail logs.
>
> Which program's responsibility is it?

In my debian 10 machines, it's configured in /etc/logrotate.d/rsyslog
belonging to the package rsyslog.
--
Nick
Reply | Threaded
Open this post in threaded view
|

Re: logrotate script for Postfix

Wietse Venema
In reply to this post by Fourhundred Thecat
Fourhundred Thecat:
> Hello,
>
> I am using Postfix on Debian. I have noticed that my mail logs are not
> being rotated.
>
> I see that there is no rule in my /etc/logrotate.d/ for rotating mail logs.
>
> Which program's responsibility is it?

If the log is written by (r)syslogd, you must use the tool that
rotates (r)syslogd logs. This ensures that (r)syslogd stops writing
to a file before it is compressed. The name of the program is
distribution dependent.

If the log is written by Postfix you must use "postfix logrotate".
This ensures that Postfix stops writing to a file before it is
compressed.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: logrotate script for Postfix

Larry Stone
>
> On May 9, 2020, at 9:45 AM, Wietse Venema <[hidden email]> wrote:
>
>
> If the log is written by Postfix you must use "postfix logrotate".
> This ensures that Postfix stops writing to a file before it is
> compressed.
>
> Wietse

I hate to even suggest I found a bug with Postfix, but I think I found a very minor bug.

First, despite having gone to Postfix logging over a year ago (thanks to MacOS’s weird logging system), this is the first I heard there was a Postfix logrotate command. Testing it, I did not get the rotated file name I would have expected. The bug is the default name for the rotated file which is from the parameter maillog_file_rotate_suffix:
# postconf -d maillog_file_rotate_suffix
maillog_file_rotate_suffix = %Y%M%d-%H%M%S

This is putting minutes where month should be. And it’s documented that way at http://www.postfix.org/MAILLOG_README.html (so technically not a bug since it works as documented but not as one would expect).

Easy fix with an override in main.cf

--
Larry Stone
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: logrotate script for Postfix

sashk
%M - minute
%m - month.
 
you have a typo, should be:
 
maillog_file_rotate_suffix = %Y%m%d-%H%M%S
 


09.05.2020, 11:32, "Larry Stone" <[hidden email]>:

 On May 9, 2020, at 9:45 AM, Wietse Venema <[hidden email]> wrote:


 If the log is written by Postfix you must use "postfix logrotate".
 This ensures that Postfix stops writing to a file before it is
 compressed.

         Wietse


I hate to even suggest I found a bug with Postfix, but I think I found a very minor bug.

First, despite having gone to Postfix logging over a year ago (thanks to MacOS’s weird logging system), this is the first I heard there was a Postfix logrotate command. Testing it, I did not get the rotated file name I would have expected. The bug is the default name for the rotated file which is from the parameter maillog_file_rotate_suffix:
# postconf -d maillog_file_rotate_suffix
maillog_file_rotate_suffix = %Y%M%d-%H%M%S

This is putting minutes where month should be. And it’s documented that way at http://www.postfix.org/MAILLOG_README.html (so technically not a bug since it works as documented but not as one would expect).

Easy fix with an override in main.cf

--
Larry Stone
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Minor logrotate bug (was Re: logrotate script for Postfix)

Larry Stone
In reply to this post by Larry Stone
I posted the note below Saturday but having seen no acknowledgement from Wietse, wanted to make sure it wasn’t overlooked although it’s very minor.

To summarize what’s below, the default value of maillog_file_rotate_suffix is %Y%M%d-%H%M%S which puts minutes where you expect month. It should be %Y%m%d-%H%M%S.

And as I said, it’s technically not a bug because it works as documented but as documented and as works is not what one would reasonably expect.

I’m running Postfix 3.5.1.

--
Larry Stone
[hidden email]





> On May 9, 2020, at 10:31 AM, Larry Stone <[hidden email]> wrote:
>
>>
>> On May 9, 2020, at 9:45 AM, Wietse Venema <[hidden email]> wrote:
>>
>>
>> If the log is written by Postfix you must use "postfix logrotate".
>> This ensures that Postfix stops writing to a file before it is
>> compressed.
>>
>> Wietse
>
> I hate to even suggest I found a bug with Postfix, but I think I found a very minor bug.
>
> First, despite having gone to Postfix logging over a year ago (thanks to MacOS’s weird logging system), this is the first I heard there was a Postfix logrotate command. Testing it, I did not get the rotated file name I would have expected. The bug is the default name for the rotated file which is from the parameter maillog_file_rotate_suffix:
> # postconf -d maillog_file_rotate_suffix
> maillog_file_rotate_suffix = %Y%M%d-%H%M%S
>
> This is putting minutes where month should be. And it’s documented that way at http://www.postfix.org/MAILLOG_README.html (so technically not a bug since it works as documented but not as one would expect).
>
> Easy fix with an override in main.cf
>
> --
> Larry Stone
> [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Minor logrotate bug (was Re: logrotate script for Postfix)

Wietse Venema
Larry Stone:
> I posted the note below Saturday but having seen no acknowledgement from Wietse, wanted to make sure it wasn?t overlooked although it?s very minor.
>
> To summarize what?s below, the default value of maillog_file_rotate_suffix is %Y%M%d-%H%M%S which puts minutes where you expect month. It should be %Y%m%d-%H%M%S.
>
> And as I said, it?s technically not a bug because it works as documented but as documented and as works is not what one would reasonably expect.
>
> I?m running Postfix 3.5.1.

I fixed this in the pending stable release updates, and it's
been available the on-line manpages and unstable releases.

        Wietse