Last active
August 28, 2017 08:35
-
-
Save alexalouit/11040751 to your computer and use it in GitHub Desktop.
Automatic purge of spam emails and trash that are aged 14 days over
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# cron ex: 1 0 * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/mail-purge.sh >> /root/scripts/cron.log | |
# Search messages more than 14 days in the appropriate directories and removes | |
find /var/vmail/ -regex '.*/\.\(Trash\|Junk\|Deleted\ Messages\)\(/.*\)?\/\(cur\|new\)/.*' -type f -ctime +14 -delete | |
# Dovecot is restarted to refresh quota (to update the .quotausage file) | |
/etc/init.d/dovecot restart | |
# since version ~2.2 (need userdb iterate): | |
#doveadm expunge -A mailbox Trash savedbefore 14d | |
#doveadm expunge -A mailbox Junk savedbefore 14d | |
#doveadm expunge -A mailbox Deleted\ Messages savedbefore 14d | |
#doveadm quota recalc -A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment