Re: question about monthly clean up mbox script
David Coppit <[email protected]> Tue, 6 Nov 2007 12:13:54 -0500 (EST)
| Newsgroups | gmane.mail.grepmail.general |
|---|---|
| Message-ID | <[email protected]> |
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(); David _____________________________________________________________________ David Coppit [email protected] The College of William and Mary http://coppit.org/ This time, let's elect a representative instead of a leader. ------------------------------------------------------------------------- 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/