|
Home > Archive > Unix Shell > April 2004 > editing the root mail file in /var/spool/mail
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
editing the root mail file in /var/spool/mail
|
|
| visvid 2004-04-22, 11:36 am |
| 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
| |
| Charles Demas 2004-04-22, 12:36 pm |
| In article <544c86db.0404220733.5860ec63@posting.google.com>,
visvid <simon@pro-tel.co.uk> wrote:
>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,
Stay Fit | @ @ | If a man waited to do it so well,
Die Anyway | v | That no one could find fault with it.
demas@theworld.com | \___/ | http://world.std.com/~cpd
| |
| Alan Connor 2004-04-22, 1:37 pm |
| On 22 Apr 2004 08:33:59 -0700, visvid <simon@pro-tel.co.uk> wrote:
>
>
> 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
| |
| Kevin Rodgers 2004-04-23, 1:34 pm |
| Alan Connor wrote:
> On 22 Apr 2004 08:33:59 -0700, visvid <simon@pro-tel.co.uk> wrote:
>
> 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
| |
| Alan Connor 2004-04-23, 2:34 pm |
| On Fri, 23 Apr 2004 11:26:52 -0600, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
>
>
> Alan Connor wrote:
>
> 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.
>
>
> 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
| |
| Kevin Rodgers 2004-04-23, 6:35 pm |
| Alan Connor wrote:
> On Fri, 23 Apr 2004 11:26:52 -0600, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
>
> 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
|
|
|
|
|