Michael Orlitzky wrote:
Justin C. Le Grice wrote:
Barney Desmond wrote:
2009/8/24 Justin C. Le Grice <mailingli...@legrice.co.nz>:
Ideally, the script would find all subdirectories of /var/vmail
containing the string "Maildir/.Spam/" and then delete the messages in
those directories which are older than 365 days. But it's buggy.
First of all, if you copy-and-pasted the code exactly, the apostrophes
around the sed command most likely did not come through, nor did the
quotes around grep's argument. That page uses HTML entities for angled
quotes, rather than plain ASCII ones. Fortunately, sed and grep will
crash, rather than, say, passing all of your files to the "rm" command.
Second, it's grepping for a path containing "Maildir/.Spam/" and then
trying to delete within that path. Try running "find" somewhere on
your machine. Do the directories end with slashes? Not here, they
don't. So, the script doesn't even empty the .Spam folder. It /almost/
empties the subdirectories of the .Spam folder, but the author is
missing two front slashes in his find commands. For example, given the
following directory structure,
$ ls /var/vmail/example.com/user/Maildir/.Spam/
drwxr-xr-x 2 mjo mjo 4.0K 2009-08-25 00:32 old-spam
-rw-r--r-- 1 mjo mjo 0 2009-08-25 00:32 test.msg
The script will try to execute the (truncated) commands:
find /var/vmail/example.com/user/Maildir/.Spam/old-spamnew/ ...
find /var/vmail/example.com/user/Maildir/.Spam/old-spamcur/ ...
which are clearly incorrect.
Third, if you followed the workaround.org tutorial, you don't even
have .Spam folders, you have .spam folders, and the case of the 's'
matters.
You don't want to run a script like this (as root!) without knowing
what it does. One misplaced front slash or period could cause you to
erase the entire filesystem. You can cause similar damage with cron if
you just follow some stranger's advice without making sure you
understand what you're doing.
Finally, the workaround.org tutorial involves Dovecot, which already
has a plugin to do exactly what you want:
http://wiki.dovecot.org/Plugins/Expire
The setup is a little painful, but it's The Right Way To Do It. Help
can be found on the Dovecot mailing list. And please, forget
everything you read on that script's website.
Thank you very much Michael.
This is most helpful and to paraphrase you "Use the right tool for the
job". Which was why I posted the message initially.
Now off to find Dovecot mailing list join instructions and read about
Expire.
Cheers.