Skip to content

Instantly share code, notes, and snippets.

@paceline
Created April 15, 2014 22:04
Show Gist options
  • Save paceline/10781525 to your computer and use it in GitHub Desktop.
Save paceline/10781525 to your computer and use it in GitHub Desktop.
Simple script for automatically emptying Spam and Trash folder
#!/bin/bash
#
# Simple script for automatically emptying Spam and Trash folders
#
# Ulf Möhring <ulf@moehring.me>
#
echo "[Mail scripts] Emptying users' trash and spam folders..."
for email in $(find /var/mail/vhosts/*/* -regextype sed -regex ".*/\.\(Trash\|Spam\)/\(cur\|new\)/.*" -type f -mtime +30); do
rm -f "${email}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment