Page 1 of 1

Auto-Cleanup Script

Posted: Fri Jan 12, 2007 3:11 am
by mito
Hey there everyone,

Just got done tweaking this simple yet highly-useful script for myself and thought I would share it. If there is enough interest in it I will add it to the wiki, but didn't want to clog-up the space on the wiki with this if there's no interest.

It's just a small script that will go through every user and delete any old messages in a certain top-level folder. I ended up writing it as I had been asking users to cleanup their mailboxes and they said they had, yet some still had mailboxes over 300mb in size. When I checked, it was because their junk-mail box had over 3000 emails in it... they didn't know they had to clean that out too.

So, since there were too many of those people to count, I wrote this script. It's simple and pretty quick if you schedule it often enough.

It skips the admin accounts, even though they theoretically shouldn't have the junk anyways. This script will delete any mail in the "Junk E-mail" folder that is 4 days old. It should be pretty obvious what you should change if you need to change something, if not, the 'man omtidyu' comes in real handy.

Code: Select all

#!/bin/bash

omshowu -m all | egrep -v 'sxadmin|sxqueryadmin' | while read username
do
    echo "Processing User $username"
    omtidyu -B -u "$username" -T f -l "Junk E-mail" -d -k -c -a 4
done


Just throw this into a file, make it executable, cron it, and you should be all set.

Is this useful enough for the wiki? Or is this something that everyone else already did but I just now got around to doing it?

Mito

Posted: Fri Jan 12, 2007 1:46 pm
by dkelly
Everything is useful for the wiki. Post it up there and then publish the link.

Cheers

Dave

Posted: Tue Jan 16, 2007 10:49 am
by mito
Ok, I just got around to putting it on the wiki, but it's there now:

http://www.scalix.com/wiki/index.php?ti ... il_Cleanup

Have fun... nothing really that elegant, but it's useful for me.