LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 06-29-2009, 02:18 PM   #1
rcrosoer
Member
 
Registered: Oct 2005
Distribution: SuSe
Posts: 41

Rep: Reputation: 15
How can I automatically delete old emails in Postfix


Hi all,

I am setting up a mail server using Postfix and would like to automatically delete emails remaining in any of the mailboxes if they exceed a predetermined age, say 14 days.

Can anyone recommend an app or script that will do this?
 
Old 06-30-2009, 11:13 PM   #2
elfoozo
Member
 
Registered: Feb 2004
Location: MI
Distribution: debian unstable
Posts: 252

Rep: Reputation: 32
Postfix doesn't have mailboxes. It's just the agent that delivers the messages to your mailboxes. You may want to include how your mailboxes are stored mbox, mysql, etc, for your set up.
 
Old 07-01-2009, 02:59 AM   #3
rcrosoer
Member
 
Registered: Oct 2005
Distribution: SuSe
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by elfoozo View Post
Postfix doesn't have mailboxes. It's just the agent that delivers the messages to your mailboxes. You may want to include how your mailboxes are stored mbox, mysql, etc, for your set up.
Would that be Courier IMAP/POP3?
 
Old 07-01-2009, 03:31 AM   #4
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
If they are in maildir format, use find.

something like
Code:
find /home -type f -name "*/Maildir/cur/*" -mtime +13 -exec rm {} \;
 
Old 07-07-2009, 12:02 PM   #5
rcrosoer
Member
 
Registered: Oct 2005
Distribution: SuSe
Posts: 41

Original Poster
Rep: Reputation: 15
Hi billymayday,

Sorry for the delay but I've been away for a few days.


Your "find" routine looks promising but I have a couple of problems.

I get an error message if I put "/path/cur" in the name pattern field
"find: warning: Unix filenames usually don't contain slashes (though pathnames do). That means that '-name `/*'' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'. Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ `/*''."


emails are located at the following

/var/vmail/domainname/mailboxname/cur/
/var/vmail/domainname/mailboxname/new/
/var/vmail/domainname/mailboxname/tmp/
/var/vmail/domainname/mailboxname/.spam/cur/
/var/vmail/domainname/mailboxname/.spam/new/
/var/vmail/domainname/mailboxname/.spam/tmp/

I have tried the following:
Code:
find /var/vmail/*/*/cur/ -type f -name "*" -mtime +13 -exec rm {} \;
and it seems to work ok.
So if I set up a daily cron job using the six locations above hopefully that will do the job.

Thanks for your help
 
Old 07-07-2009, 08:59 PM   #6
sleddog
Member
 
Registered: Jan 2002
Location: Labrador, Canada
Distribution: CentOS, Debian
Posts: 182

Rep: Reputation: 35
You could also have a look at http://svn.houseofnate.net/unix-tool...leanup-maildir
 
Old 07-07-2009, 10:18 PM   #7
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Quote:
Originally Posted by rcrosoer View Post
Hi billymayday,

Sorry for the delay but I've been away for a few days.


Your "find" routine looks promising but I have a couple of problems.

I get an error message if I put "/path/cur" in the name pattern field
"find: warning: Unix filenames usually don't contain slashes (though pathnames do). That means that '-name `/*'' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'. Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ `/*''."


emails are located at the following

/var/vmail/domainname/mailboxname/cur/
/var/vmail/domainname/mailboxname/new/
/var/vmail/domainname/mailboxname/tmp/
/var/vmail/domainname/mailboxname/.spam/cur/
/var/vmail/domainname/mailboxname/.spam/new/
/var/vmail/domainname/mailboxname/.spam/tmp/

I have tried the following:
Code:
find /var/vmail/*/*/cur/ -type f -name "*" -mtime +13 -exec rm {} \;
and it seems to work ok.
So if I set up a daily cron job using the six locations above hopefully that will do the job.

Thanks for your help
Why not just
Code:
find /var/vmail/*/* -type f -mtime +13 -exec rm {} \;
and one cronjob?

Last edited by billymayday; 07-07-2009 at 10:19 PM.
 
Old 07-10-2009, 02:40 AM   #8
rcrosoer
Member
 
Registered: Oct 2005
Distribution: SuSe
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by billymayday View Post
Why not just
Code:
find /var/vmail/*/* -type f -mtime +13 -exec rm {} \;
and one cronjob?
I have webmail on board and there are a load of other housekeeping files. It seemed simpler than a long purge list.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Line To Delete Emails In Inbox gaspower Linux - Newbie 2 05-06-2008 05:58 PM
How can I automatically open HTML links sent in emails? bad_andy Linux - General 6 01-01-2005 07:42 AM
Evolution Ximian crashes trying to delete emails in Outbox Maurice Arthur Mandriva 4 05-04-2004 10:06 PM
Fastest way to delete all emails remotely? mldqj Linux - Networking 4 04-29-2004 03:12 PM
how to delete too many emails in my box? linuxboy_inside Linux - Newbie 2 12-11-2003 09:29 PM


All times are GMT -5. The time now is 01:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration