Groups > Unix Linux > Linux general discussion > Re: Mail removal after X amount of days




Mail removal after X amount of days

Mail removal after X amount of days
Tue, 12 Feb 2008 08:52:19 +020
Hi,

Is there perhaps a tool I could run via cron that looks at all mailboxes on 
my server
and removes email older than X amount of days.

Thanks in advance.
-- 
Leo 

Post Reply
Re: Mail removal after X amount of days
Tue, 12 Feb 2008 19:52:13 +000
On Tue, 12 Feb 2008 08:52:19 +0200, Leonard wrote:

> Is there perhaps a tool I could run via cron that looks at all mailboxes
> on my server and removes email older than X amount of days.

This really depends on how your mail is stored, mbox or maildir. If in 
mbox format then you will have more of a challenge than if you are using 
maildir (just IMO of course). In any case I would probably write my own 
script to do this were I wanting to do the same. Either that or I would 
find a script someone else has posted on "the web" and modify it for
my 
use.

Instead of deleting old mail why not just use mailbox quotas that limit 
how much mail your users can store before they run out of space? I've 
never had to use these myself but most server-side mail systems have some 
sort of quota mechanism.

HTH
Gene (e-mail: gene \a\t eracc \d\o\t com)
-- 
Mandriva Linux release 2007.1 (Official) for i586
Got Rute? http://www.anrdoezrs.net/email-2546588-42121?isbn=0130333514
ERA Computers & Consulting - http://www.eracc.com/
Post Reply
Re: Mail removal after X amount of days
Wed, 20 Feb 2008 14:21:22 -050
ERACC wrote:
> On Tue, 12 Feb 2008 08:52:19 +0200, Leonard wrote:
> 
>> Is there perhaps a tool I could run via cron that looks at all
mailboxes
>> on my server and removes email older than X amount of days.
> 
> This really depends on how your mail is stored, mbox or maildir. If in 
> mbox format then you will have more of a challenge than if you are using 
> maildir (just IMO of course). In any case I would probably write my own 
> script to do this were I wanting to do the same. Either that or I would 
> find a script someone else has posted on "the web" and modify it
for my 
> use.
> 
> Instead of deleting old mail why not just use mailbox quotas that limit 
> how much mail your users can store before they run out of space? I've 
> never had to use these myself but most server-side mail systems have some 
> sort of quota mechanism.
> 
> HTH
> Gene (e-mail: gene \a\t eracc \d\o\t com)


   To OP:

   How much have you googled?

   I googled it a little bit and it seems like it's just a simple little 
bash script that can fix it for you.

#!/bin/bash

find /u1/database/prod/arch -type f -mtime +3 -exec rm {} \;

Change find and mtime to the time that you want.  It's better to pipe it 
to use xarg as demonstrated in the linuxquestions.org link

   Good luck,

      Tell us how it goes.


  http://www.thescripts.com/forum/thread617579.html
 
http://www.linuxquestions.org/questions/linux-general-1/bash-script-to-remove-fi
les-older-than-3-days-462290/

Post Reply
about | contact