LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-21-2010, 02:36 AM   #1
oduori
LQ Newbie
 
Registered: Jun 2010
Distribution: Centos/Fedora
Posts: 1

Rep: Reputation: 0
Auto delete mails from postfix server after 1 month


How do I make my postfix mail server auto delete mails from user mailboxes after say 1 or 2 months?
 
Old 07-18-2010, 07:50 AM   #2
manorina
LQ Newbie
 
Registered: Jan 2008
Location: Eastern Australia
Distribution: Mint 6, 7, Ubuntu 9.04
Posts: 18

Rep: Reputation: 1
Hi Oduori,

I would suggest that you could do this with a cron job. cron is a program which can run other programs periodically. You could write a very short shell script which finds files (those files being mail messages you want to delete) which are older than 1 month and then delete them. You can then run the shell script every day as a cron job for user root.

This will delete files older than 30 days old

Code:
find /path/to/mailmsgs -mtime +30 -delete
*BEWARE* - test this code on unimportant files first, otherwise you can get a nasty shock and lose files.

Put this code in a scripts file, let's call it rm_old_mail.sh

Using crontab -e you can create a cron job for user root. Just google crontab examples to get some information on how to use cron. Then you would run the rm_old_mail.sh script everyday at 1am, for example.
 
  


Reply

Tags
auto, delete


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
move mails on exim server to postfix server weda Linux - Server 1 01-13-2010 02:12 AM
To restrict a user to send mails only to 3 e-mails IDs using postfix mail server sharath41 Linux - Newbie 2 07-21-2008 07:38 PM
auto delete old mails in sendmail - Pls Help maharajg Linux - Networking 3 11-10-2004 11:21 AM
move postfix mails from server to another postfix server onetwo Linux - Software 2 03-18-2003 02:22 PM
How do I auto delete mails from a specific domains/users? markng Linux - Security 4 05-02-2002 10:41 PM


All times are GMT -5. The time now is 08:11 PM.

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