Scott Wiersdorf Created: Thu Apr 8 23:23:58 MDT 2004 $Id: index.html,v 1.1 2005/08/15 18:25:30 scott Exp $mail_newer - the mail_newer script
mail_newer prints a mail message if it is newer than a specified number of days. mail_newer is non-destructive: it does not operate on mailboxes directly, but prints matching messages to stdout.
mail_newer version: 1.2
mail_newer2 version: 1.2
formail -s mail_newer 7 < /home/foo/mbox > /home/foo/mbox.newmbox.new contains the messages that have been received in the past 7 days.
To run from cron on a shared hosting platform (e.g., viaVerio Signature), do this (courtesy Sherman Pierce):
23 5 * * * formail -s $HOME/path/to/mail_newer 10 < $HOME/users/joe/mail/Trash > $HOME/users/joe/mail/Trash2 && mv $HOME/users/joe/mail/Trash2 $HOME/users/joe/mail/Trashor on a VPS v2 (in /etc/crontab):
SHELL=/bin/sh 23 5 * * * joe_user formail -s /path/to/mail_newer 10 < $HOME/Mail/Trash > $HOME/Mail/Trash2 && mv $HOME/Mail/Trash2 $HOME/Mail/Trash
formail -s mail_newer 7 < mbox > mbox.new && mv mbox.new mboxbut the race condition still exists (though is very small). mail_newer is safe to run on mail archives and other non-live mailboxes.
System Administration tutorials
Send comments to the author