Trash under home mail folder

Rushan Sobar Rushan at mec.com.jo
Sun Mar 6 12:53:19 UTC 2005


----- Original Message ----- 
From: "Steve Buehler" <steve at ibapp.com>
To: "General Red Hat Linux discussion list" <redhat-list at redhat.com>; 
"Rushan Sobar" <Rushan at mec.com.jo>
Sent: Sunday, March 06, 2005 3:52 AM
Subject: Re: Trash under home mail folder


> At 06:19 PM 3/4/2005, you wrote:
>
>>Hi,
>>
>>Anyone can advice how i can clear all the user's trash at once?
>>lets say users send there junk and unwanted e-mails to trash and they 
>>forget to delete it so in the under each user mail home directory there is 
>>trash , how to delete all at once??
>
> Couple of ways.  If everybody is in /home/accountname for their accounts, 
> you could probably just do a:
> rm -f /home/*/Trash
> Change "Trash" to the name of their trash box....which could be 
> "INBOX.Trash"
> or there is a program called archivemail you can get at:
> http://archivemail.sourceforge.net/
> Read the directions and make sure that the first time you run it, you use 
> the "--dry-run" option.  That will show you how many emails would have 
> been deleted, without deleting them.
> For what you are doing, you could just do:
> archivemail --dry-run -d 1 --delete /home/*/Trash
>
> I have a little script that I run in my /etc/cron.daily to do this for me, 
> except it lets them keep email for up to 6 months (183 days) in any of 
> their mailboxes.  I have added a few extra comments for you.
> -----start of script /etc/cron.daily/00cleanmailboxes-----
> #!/bin/bash
> # The "result" below is getting a list of all mailboxes
> # (basically accounts on the system that has received email in the past)
> result=(`/bin/ls -1 /var/spool/mail`)
>
> # Now, run through a loop to clean of those mailboxes
> for e in "${result[@]}"; do
>
> # put an "-n", or "--dry-run" in the archivemail command for testing
> # From the man pages for the "-n" or "--dry-run" options:
> # (next 3 comment lines)
> # Don't write to any files -- just show what would have been done.
> # This is useful for testing to see how many messages would have
> # been archived.
>
> # The next line deletes any mail in those mailboxes older than 183 days 
> old
>         /usr/bin/archivemail -d 183 --delete /var/spool/mail/$e
>
> # If you only want to delete what they have in their imap Trash mailbox,
> # than comment out the above line and all lines below this line but
> # "NOT" the "done" line and uncomment the following line
> #       /usr/bin/archivemail -d 183 --delete "/home/$e/Trash"
> # For those users that use imap programs like Squirrelmail, this will run 
> through
> # their mailboxes in their home directories and delete those after 183 
> days too.
>         if [ -r "/home/$e/.mailboxlist" ]
>         then
>                 exec 6< /home/$e/.mailboxlist
>                 while read -u 6 dta
>                 do
>                 /usr/bin/archivemail -d 183 --delete "/home/$e/$dta"
>                 done
>         fi
>         exec 6<&-
> done
> -----start of script /etc/cron.daily/00cleanmailboxes-----
>
> The "archivemail" program was a blessing for me because one of our servers 
> has over 15,000 email accounts on it and this just makes it so much 
> easier.  The program will also backup emails older than # days and a few 
> other things.  It is worth a million bucks, but is free
>
> Hope this helps.
> Steve

Thanks Steve, :)
really it is worth a million!
Done and working fine.

Regards
Rushan




-- 
This message has been scanned for viruses and
dangerous content by MEC E-Mail Scanner, and is
believed to be clean.
--
www.mec.com.jo




More information about the redhat-list mailing list