procmail
[Top] [All Lists]

Re: Auto removal of older mail

1998-05-07 10:02:18
The following script enables you to save your mail
to a folder called 19980506 (or whatever today is).
What you can do is when mail arrives you can decide to delete
mailboxes which don't start with:
199805
or
1998050

or  199805

To be selected as old.

Note this script creates a file in /tmp that does the
following:
cat >> 19980506 

The mail lines are piped into that command.  You
should put the path you want before the 1998
to be sure it goes where you want.

0: "/home/myuser/today"
| awk -F '\012'  -f datefiler.awk

You use the END{ part of the awk script to do:
     ls -al PATTERN |  cut -c 58- | sort | sed 's/^/rm /g' > deljob ;
sh < deljob

The sort command will put them from the oldest
to the newest.  You will be deleting the oldest
mailfolders with that command.  

PATTERN is the dates you want to delete based
on today's dates.

You need to exclude today's folders.

-- Where datefilter.awk is --

BEGIN{ 
    SHELL = "/bin/ksh"
    x = 34
    printf("date +%c%%Y%%m%%d%c | sed 's/^/cat \>\> /g' >
/tmp/today",x,x) | SHELL 
    print "chmod ugo +x /tmp/today | SHELL 
    }
{
    print $1 | "/tmp/today"
}
END{
     (delete 10 oldest mailfolders)
   }

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

<Prev in Thread] Current Thread [Next in Thread>