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:
|
2023-08-10 21:47:21 +02:00
|
|
|
# 50 * * * * /path/to/cleanmaildir
|
2014-09-13 21:23:13 +02:00
|
|
|
|
2023-08-10 21:47:21 +02:00
|
|
|
etcfile=/usr/local/etc/cleanmaildir.conf
|
2014-09-13 21:23:13 +02:00
|
|
|
|
2023-08-10 21:47:21 +02:00
|
|
|
grep -v '^#' < $etcfile | while IFS= read -r i
|
2014-09-13 21:23:13 +02:00
|
|
|
do
|
2023-08-10 21:47:21 +02:00
|
|
|
dir=$(echo "$i" | cut -f 1 -d ,)
|
|
|
|
time=$(echo "$i" | cut -f 2 -d ,)
|
|
|
|
find "$HOME/Maildir/$dir/cur/" -type f -mtime +$(( time - 1)) -exec rm '{}' \;
|
2014-09-13 21:23:13 +02:00
|
|
|
done
|