editing the root mail file in /var/spool/mail

editing the root mail file in /var/spool/mail

Post by visv » Sat, 24 Apr 2004 00:33:59



var/spool/mail  I want to set up a cron job that would look at the
various  mail files and keep only  4 weeks worth.

Anyone got any ideas or suggestions on this ?

Cheers

visivd

 
 
 

editing the root mail file in /var/spool/mail

Post by Charles Dem » Sat, 24 Apr 2004 01:12:47




>var/spool/mail  I want to set up a cron job that would look at the
>various  mail files and keep only  4 weeks worth.

>Anyone got any ideas or suggestions on this ?

Use procmail to deliver mail to one of 28 or 29 directories.
Then use cron to delete everything in the appropriate
oldest of those 28 or 29 28 or 29 directories, and set which
directory mail is delivered to.

Chuck Demas

--
  Eat Healthy        |   _ _   | Nothing would be done at all,

  Die Anyway         |    v    | That no one could find fault with it.


 
 
 

editing the root mail file in /var/spool/mail

Post by Alan Conno » Sat, 24 Apr 2004 02:12:46



Quote:

> var/spool/mail  I want to set up a cron job that would look at the
> various  mail files and keep only  4 weeks worth.

> Anyone got any ideas or suggestions on this ?

> Cheers

> visivd

Use formail to add a received date header to each incoming mail,
with the date in seconds since 1970.

Then have csplit break up the contents of $MAIL into seperate
temporary files in a temporary directory and loop through
them deleting any files with a received date header date earlier
than 2592000 seconds before the present.

Then cat the survivors back together in $MAIL and remove the temp files
and dir....

You need GNU date for this, but didn't tell us what OS you were using....

AC

--
Pass-List -----> Block-List ----> Challenge-Response
The key to taking control of your mailbox.
Design Parameters: http://tinyurl.com/2t5kp
http://tinyurl.com/3c3ag  Challenge-Response links -- http://tinyurl.com/yrfjb

 
 
 

editing the root mail file in /var/spool/mail

Post by Kevin Rodger » Sun, 25 Apr 2004 02:26:52



 >>var/spool/mail  I want to set up a cron job that would look at the
 >>various  mail files and keep only  4 weeks worth.
 >
 > Use formail to add a received date header to each incoming mail,
 > with the date in seconds since 1970.

That's a really good idea, but use procmail to do it when each message
is delivered to the $MAIL spool file.

 > Then have csplit break up the contents of $MAIL into seperate
 > temporary files in a temporary directory and loop through
 > them deleting any files with a received date header date earlier
 > than 2592000 seconds before the present.
 >
 > Then cat the survivors back together in $MAIL and remove the temp files
 > and dir....

But instead of that, why not have the cron job reprocess the $MAIL spool
file with formail, discarding the old messages and writing the recent
messages to $MAIL.recent; then mv $MAIL.recent $MAIL.

 > You need GNU date for this, but didn't tell us what OS you were using....

--
Kevin Rodgers

 
 
 

editing the root mail file in /var/spool/mail

Post by Alan Conno » Sun, 25 Apr 2004 03:06:58





> >>var/spool/mail  I want to set up a cron job that would look at the
> >>various  mail files and keep only  4 weeks worth.

> > Use formail to add a received date header to each incoming mail,
> > with the date in seconds since 1970.

> That's a really good idea, but use procmail to do it when each message
> is delivered to the $MAIL spool file.

That's a good idea too.

Quote:

> > Then have csplit break up the contents of $MAIL into seperate
> > temporary files in a temporary directory and loop through
> > them deleting any files with a received date header date earlier
> > than 2592000 seconds before the present.

> > Then cat the survivors back together in $MAIL and remove the temp files
> > and dir....

> But instead of that, why not have the cron job reprocess the $MAIL spool
> file with formail, discarding the old messages and writing the recent
> messages to $MAIL.recent; then mv $MAIL.recent $MAIL.

Do you mean something like:

cat $MAIL | formail -s procmail ~/.procmailrc2 &&
mv $MAIL.recent $MAIL

Where ~/.procmailrc2 is:

SHELL=/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin
DEFAULT=$MAIL.recent

:0 f
| script that compares X-Received-Date to `date +%s`  and dumps those that fail

:0
${DEFAULT}

??

If not, what?

AC

 
 
 

editing the root mail file in /var/spool/mail

Post by Kevin Rodger » Sun, 25 Apr 2004 06:10:11



 >>But instead of that, why not have the cron job reprocess the $MAIL spool
 >>file with formail, discarding the old messages and writing the recent
 >>messages to $MAIL.recent; then mv $MAIL.recent $MAIL.
 >
 > Do you mean something like:
 >
 > cat $MAIL | formail -s procmail ~/.procmailrc2 &&
 > mv $MAIL.recent $MAIL
 >
 > Where ~/.procmailrc2 is:
 >
 > SHELL=/bin/sh
 > PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin
 > DEFAULT=$MAIL.recent
 >
 > :0 f
 > | script that compares X-Received-Date to `date +%s`  and dumps those that fail
 >
 > :0
 > ${DEFAULT}

Yep, that's what I meant.  I'm not a very experienced procmail user,
though, so I can only assume ~/.procmailrc2 does what we intend.  And if
possible, I would want to find a way to pass the $MAIL.recent file name
into formail so that the dependency would be made explicit.

--
Kevin Rodgers