Auto-Cleanup Script

Discuss the Scalix Server software

Moderators: ScalixSupport, admin

mito
Posts: 194
Joined: Fri Mar 24, 2006 11:33 am

Auto-Cleanup Script

Postby mito » Fri Jan 12, 2007 3:11 am

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

dkelly
Scalix
Scalix
Posts: 593
Joined: Thu Mar 18, 2004 2:03 pm

Postby dkelly » Fri Jan 12, 2007 1:46 pm

Everything is useful for the wiki. Post it up there and then publish the link.

Cheers

Dave

mito
Posts: 194
Joined: Fri Mar 24, 2006 11:33 am

Postby mito » Tue Jan 16, 2007 10:49 am

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.


Return to “Scalix Server”



Who is online

Users browsing this forum: No registered users and 9 guests