scripts/cleanmaildir.sh

25 lines
584 B
Bash
Raw Normal View History

2014-09-13 21:23:13 +02:00
#!/bin/sh
#
# simple shell script to clean some subdirectories of a maildir
#
# format of $etcfile is:
# dirname1,maxdays
# dirname2,maxdays
# etc...
# (one line by subdir to clean)
#
# were dirname* is the name of the subdirectory to clean,
# and maxdays is the maximum number of days before a message is deleted
#
# put it in the user's crontab:
# 50 * * * * /path/to/cleanmaildir.sh
etcfile=/etc/cleanmaildir.conf
for i in `cat $etcfile`
do
dir=`echo $i | cut -f 1 -d ,`
time=`echo $i | cut -f 2 -d ,`
find ~/Maildir/$dir/cur/* -mtime +`expr $time - 1` -exec rm '{}' \;
done