Re: [Dovecot] purge maildir folder after sa-learn

2010-06-01 Thread Phil Howard
On Sat, May 29, 2010 at 12:03, Eric Shubert  wrote:

> That's what I do. I move them either to a (shared) ham or spam folder, and
> run the script posted earlier, which processes and deletes them.

Thanks.  I just wanted to be sure such a move would not effect
(corrupt) what Dovecot was doing (e.g. indexes and such).  Glad it
won't.  That makes things simpler.


Re: [Dovecot] purge maildir folder after sa-learn

2010-05-29 Thread Eric Shubert

Phil Howard wrote:

On Wed, May 26, 2010 at 06:13, Timo Sirainen  wrote:

On Wed, 2010-05-26 at 09:56 +0200, Florian Effenberger wrote:

rm -f /path/to/Maildir/.spam-learn/*

Oh, I really ment .spam-learn/cur/* (and maybe .spam-learn/new/* if you
make it learn from both and it doesn't move mails to cur/).


Can I simply delete the files, don't I destroy any indices or slow
down Dovecot operation because of index rebuilding?

Keep Dovecot's index files around so that they won't get deleted while
Dovecot is trying to read/write them. You won't slow down anything by
manually deleting maildir files.


So basically, just moving mail files out (to a learn queue or
whatever), from either "new" or "cur" is safe for Dovecot?  That would
be simpler.



That's what I do. I move them either to a (shared) ham or spam folder, 
and run the script posted earlier, which processes and deletes them.


--
-Eric 'shubes'



Re: [Dovecot] purge maildir folder after sa-learn

2010-05-28 Thread Florian Effenberger
Hi,

2010/5/28 Phil Howard :
> So basically, just moving mail files out (to a learn queue or
> whatever), from either "new" or "cur" is safe for Dovecot?  That would
> be simpler.

works like a charm for me.

Florian


Re: [Dovecot] purge maildir folder after sa-learn

2010-05-28 Thread Phil Howard
On Wed, May 26, 2010 at 06:13, Timo Sirainen  wrote:
> On Wed, 2010-05-26 at 09:56 +0200, Florian Effenberger wrote:
>> > rm -f /path/to/Maildir/.spam-learn/*
>
> Oh, I really ment .spam-learn/cur/* (and maybe .spam-learn/new/* if you
> make it learn from both and it doesn't move mails to cur/).
>
>> Can I simply delete the files, don't I destroy any indices or slow
>> down Dovecot operation because of index rebuilding?
>
> Keep Dovecot's index files around so that they won't get deleted while
> Dovecot is trying to read/write them. You won't slow down anything by
> manually deleting maildir files.

So basically, just moving mail files out (to a learn queue or
whatever), from either "new" or "cur" is safe for Dovecot?  That would
be simpler.


Re: [Dovecot] purge maildir folder after sa-learn

2010-05-27 Thread Florian Effenberger
Hi Timo,

2010/5/26 Timo Sirainen :

> Oh, I really ment .spam-learn/cur/* (and maybe .spam-learn/new/* if you
> make it learn from both and it doesn't move mails to cur/).
>
>> Can I simply delete the files, don't I destroy any indices or slow
>> down Dovecot operation because of index rebuilding?
>
> Keep Dovecot's index files around so that they won't get deleted while
> Dovecot is trying to read/write them. You won't slow down anything by
> manually deleting maildir files.

thanks a lot, seems to work like a charm!

Florian


Re: [Dovecot] purge maildir folder after sa-learn

2010-05-26 Thread Timo Sirainen
On Wed, 2010-05-26 at 09:56 +0200, Florian Effenberger wrote:
> > rm -f /path/to/Maildir/.spam-learn/*

Oh, I really ment .spam-learn/cur/* (and maybe .spam-learn/new/* if you
make it learn from both and it doesn't move mails to cur/).

> Can I simply delete the files, don't I destroy any indices or slow
> down Dovecot operation because of index rebuilding? 

Keep Dovecot's index files around so that they won't get deleted while
Dovecot is trying to read/write them. You won't slow down anything by
manually deleting maildir files.




Re: [Dovecot] purge maildir folder after sa-learn

2010-05-26 Thread Florian Effenberger
Hello everyone,

thanks for the fast replies, much appreciated!

2010/5/25 Timo Sirainen :

>> I am looking for a command-line utility to automatically purge one
>> Maildir folder.
>
> How about just:
>
> rm -f /path/to/Maildir/.spam-learn/*
>
> With v2.0 you can also do:
>
> doveadm expunge -u username mailbox spam-learn all

I run 1.x, so doeveadm doesn't exist. :-)
Can I simply delete the files, don't I destroy any indices or slow
down Dovecot operation because of index rebuilding? Sounds like a
simple solution I also thought of, but I was hesitant of just deleting
the files...

Thanks,
Florian


Re: [Dovecot] purge maildir folder after sa-learn

2010-05-25 Thread William Blunn

On 25/05/2010 21:10, Timo Sirainen wrote:

On Tue, 2010-05-25 at 21:29 +0200, Florian Effenberger wrote:
   

Hello,

I am looking for a command-line utility to automatically purge one
Maildir folder.
 

How about just:

rm -f /path/to/Maildir/.spam-learn/*
   


Surely we need to delete everything in 'new' and 'cur'? :

rm -f /path/to/Maildir/.spam-learn/new/* /path/to/Maildir/.spam-learn/cur/*

Or perhaps, a bit more pipey and less risk of blowing up whilst globbing 
in the shell:


maildir=/path/to/Maildir/.spam-learn find $maildir/new $maildir/cur 
-mindepth 1 -maxdepth 1 -type f -print0 | xargs -0 -r rm -f


Regards,

Bill


Re: [Dovecot] purge maildir folder after sa-learn

2010-05-25 Thread Timo Sirainen
On Tue, 2010-05-25 at 21:29 +0200, Florian Effenberger wrote:
> Hello,
> 
> I am looking for a command-line utility to automatically purge one
> Maildir folder. 

How about just:

rm -f /path/to/Maildir/.spam-learn/*

With v2.0 you can also do:

doveadm expunge -u username mailbox spam-learn all




Re: [Dovecot] purge maildir folder after sa-learn

2010-05-25 Thread Eric Shubert

Florian Effenberger wrote:

Hello,

I am looking for a command-line utility to automatically purge one
Maildir folder. I want to periodically run sa-learn from cron, and
after the spam learning folder has been added to the Bayes database,
its contents should be deleted. I've searched a bit, but only found a
few old utilities or some telnet+expect scripts, which both didn't
look too reliable.

Is there any command-line utility to delete all contents of a Maildir
folder, or is there any other solution?

Thanks,
Florian



I would write a script that cron executes, and have the script do the 
sa-learn, then delete the file.


I run qmail-toaster, which uses vpopmail for virtual domains/accounts. 
My maildirs for learning ham/spam are shared, and are named sa-learn/Ham 
and sa-learn/Spam.


Here's the script that I run in cron.daily to execute sa-learn:

#!/bin/sh
#
# learn and remove spam and ham in shared folders
#
# shubes 3/26/08 - created
#

learndir="/home/vpopmail/domains/shubes.net/sa-learn"
hambox=.Ham
spambox=.Spam

do_the_learning(){

learnas=$1
maildir=$2

shopt -s extglob
for spamfile in `find $maildir/+(cur|new)/* 2>/dev/null`; do
  sudo -u vpopmail -H sa-learn --$learnas $spamfile
  rc=$?
  if [ $? != "0" ]; then
echo "sa-learn failed, rc=$rc, spamfile=$spamfile"
exit $rc
  fi
  rm $spamfile
done
}

do_the_learning ham  "$learndir/$hambox"
do_the_learning spam "$learndir/$spambox"

exit 0
# end of script

HTH.
--
-Eric 'shubes'



[Dovecot] purge maildir folder after sa-learn

2010-05-25 Thread Florian Effenberger
Hello,

I am looking for a command-line utility to automatically purge one
Maildir folder. I want to periodically run sa-learn from cron, and
after the spam learning folder has been added to the Bayes database,
its contents should be deleted. I've searched a bit, but only found a
few old utilities or some telnet+expect scripts, which both didn't
look too reliable.

Is there any command-line utility to delete all contents of a Maildir
folder, or is there any other solution?

Thanks,
Florian