How to purge the Maildir inbox for all system accounts: /home/user/Maildir


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » Email

How to purge the Maildir inbox for all system accounts: /home/user/MaildirLast Modified: Mar 6, 2013, 1:45 am
If you're noticing that your User's System Accounts are not being checked often enough (or ever) and you wish to purge them, you can use the following script.

#!/bin/sh

#Deletes emails older than this number of days
OLD_THAN_DAYS=30

for i in `ls /usr/local/directadmin/data/users`; do
{
       if [ ! -d /home/$i/Maildir ]; then
               continue;
       fi

       for file in `find /home/$i/Maildir -mtime +${OLD_THAN_DAYS} | grep -E '/cur/|/new/'`; do
       {
               rm -fv $file;
       };
       done;
};
done;
exit 0;

Save the script, chmod to 755, and run.
This script needs to be run as root.

You can run this script as often as you wish with a cronjob to keep the system accounts trimmed.

Keep in mind that if you're deleting their data, Users may not appreciate this, so only run it if you're certain they're not checking this account.
 
Related Helpfiles
Automatically purge inbox and other IMAP folders
Cannot delete oversized directories: /bin/rm: Argument list too long

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST