Hi monks, I have a postfix logfile /var/log/maillog. I want to send a blocked mail digest to users on daily basis. ( Let's say @ 10.30 am everyday). I want to print all lines from 10.30 a.m from yesterday to 10.30 am today from this /var/log/maillog to anoter file.

Then I will grep the BLOCKED mails from this file and send a Blocked mail Digest report to users.

How can I achieve this?

I found similar urls.

Extracting Log File data for a given date range
http://stackoverflow.com/questions/21995141/perl-script-to-extract-data-from-log-file-between-two-date-ranges-not-necessary

mail maillog looks like this

Feb 1 03:10:39 mailgw postfix/smtpd[31168]: disconnect from host.doma +in.net[8.3.14.x] Feb 1 03:10:41 mailgw postfix/smtpd[31175]: connect from localhost.lo +caldomain[127.0.0.1] Feb 1 03:10:41 mailgw postfix/smtpd[31175]: 42B1A1620467: client=loca +lhost.localdomain[127.0.0.1]
and so on I am still trying to write it. Can you monks help me on this.


In reply to print lines withing specific date range from mailoog file by theravadamonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.