Re: question about monthly clean up mbox script
Dan Pritts <[email protected]> Tue, 6 Nov 2007 14:39:59 -0500
| Newsgroups | gmane.mail.grepmail.general |
|---|---|
| Message-ID | <[email protected]> |
If the mailbox happenes to be accessible via IMAP, you might look at using the mailutil program that comes with the UW imapd distribution. That way imap would handle all the locking for you. On Tue, Nov 06, 2007 at 12:13:54PM -0500, David Coppit wrote: > On Tue, 6 Nov 2007, Michiel van Es wrote: > > > I have a question, I want to use grepmail in a cronjob script to check a mbox file and remove > > al mails older then 1 month (or 2 weeks). > > I am not a guru with shell/bash scripting but perhaps someone has a little tip for me? > > The problem is that you'll want to lock the file during the operation so > that new incoming mails won't get lost. But something like this (untested) > should work: > > #!/bin/sh > > lock_mailbox_somehow(); > grepmail -d 'since 1 month ago' mailbox > tempmailbox; > mv tempmailbox > mailbox > unlock_mailbox_somehow(); > ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/