| In the 2.0 kit, we now have an "unsupported" directory
with an assortment of useful tools and scripts - one
of them is the following "janitor" script. (It should
work with 1.7, as it doesn't use any specific features
of 2.0).
-Stan
#!/bin/sh
# set -x
#######################################################################
#
# janitor.scp
#
# Script to perform some janitorial tasks on the mail server(s).
# The idea is to emulate the old All-In-1 mail janitor wherein
# we empty the users wastebaskets/trash and then place mail that
# is thirty (30) days or older in the wastebasket/trash. Then
# we send the user a message telling them that we have moved the
# aforementioned messages into the trash which will be deleted
# along with the stuff they themselves put in the trash the next
# time around (7 days) unless they refile it.
#######################################################################
#######################################################################
# Function: GetTargetDate
#
# purpose: To get a target date which is a number of days
# back from the present date.
# input: The number of days back from the present date
# to use as a target date. Set variable $OFFSET_DAYS
# The default if not provided is 30.
# output: The variable $TARGET_DATE will be set to the date.
#
#
#
GetTargetDate()
{
days_in_month_normal="31,28,31,30,31,30,31,31,30,31,30,31"
days_in_month_leap="31,29,31,30,31,30,31,31,30,31,30,31"
months_in_year="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
# Parameter #1 is the number of days to calculate back from today
# The default is 30 days
offset=30
[ "$OFFSET_DAYS" = "" ] || offset="$OFFSET_DAYS"
day=`date +%j`
year=`date +%Y`
if [ "$day" -le $offset ]
then
year=`expr $year - 1`
n=`expr $offset - $day`
day=`expr 365 - $n`
else
day=`expr $day - $offset`
fi
# Set up our array of number of days in each month based on
# whether this is a leap year or not.
if [ `expr $year % 4` -eq 0 ]
then
days_in_month="$days_in_month_leap"
else
days_in_month="$days_in_month_normal"
fi
m=1
total=0
while [ $m -le 12 ]
do
d=`echo $days_in_month | cut -f$m -d','`
if [ "`expr $total + $d`" -lt $day ]
then
total=`expr $total + $d`
else
out_month=`echo $months_in_year | cut -f$m -d','`
out_day=`expr $day - $total`
#echo "$out_month $out_day $year"
TARGET_DATE="$out_month $out_day $year"
break
fi
m=`expr $m + 1`
done
}
#######################################################################
#######################################################################
#
# Main Script
#
#
# Change this when moving the Janitorial files...
#
JANITOR_HOME=/usr/local/slib/janitor
#
#
# Make sure we have the MW command line area in our path
#
PATH=${PATH}:/usr/opt/DMW/clbin:/usr/opt/DMW/bin
export PATH
#
#
# Ask our GetTargetDate function for the date 30 days ago
#
OFFSET_DAYS=30
GetTargetDate
echo "TARGET_DATE: $TARGET_DATE"
exit 0
#
#
# Start actual cleaning - empty the trash first
#
#for USER in `cat ${JANITOR_HOME}/janitor.testlist`
for USER in `ali -g | awk -F: '{print $1}'`
do
setpms $USER
folder +${USER}//"Trash"
rmm -trash
done
#
#
# Dump old stuff into trash - 30 days or older,
# be nice and send user a message
#
#for USER in `cat ${JANITOR_HOME}/janitor.testlist`
for USER in `ali -g | awk -F: '{print $1}'`
do
setpms $USER
folder +${USER}//"Read"
refile `pick +"Read" -before "$TARGET_DATE"` +Trash
folder +${USER}//"Out Box"
refile `pick +"Out Box" -before "$TARGET_DATE"` +Trash
/usr/bin/mailx -s "Mail Cleanup" ${USER} < ${JANITOR_HOME}/janitor.msg
done
#
# Make a clean break?
folder +dmwadmin//
#
exit 0
|
| Hello Josep,
If your customer uses the Motif client, you can Query
(Alt-Q or select from Folders pulldown menu) for all messages
from Before a certain date. Then after these are highlighted
after the Query is through, select Trash to move these messages
to the Trash folder. Then select Empty Trash (from the File
pulldown menu) to truly delete these messages. This can only
be done 1 folder at a time, however.
Hope this helps,
Mary
|