[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference abbott::mailworks-unix

Title:Mailworks-unix
Notice:V2.0.4 now available -- see Note 4.375
Moderator:TAMARA::NEUMAN::Neumann
Created:Wed Jun 02 1993
Last Modified:Tue Jun 03 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1384
Total number of notes:5851

1369.0. "How to automatically delete old messages?" by BARNA::DSMAIL () Tue Apr 22 1997 09:40

Hi,

A customer using  V 1.7 (OSF) (33) would like to delete all messages
received before a date.

I was not been able to locate any way to do it.

Anybody could help us?

Regards,

		Josep
T.RTitleUserPersonal
Name
DateLines
1369.1Sample script in 2.0TAMARA::NEUMAN::NeumannStan NeumannTue Apr 22 1997 19:57150
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


1369.2Can also do from Motif client on a folder-by-folder basisMSKRAT::PAWELKOTue Apr 22 1997 22:1214
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