Cover V01, I04
Article
Listing 1
Listing 2
Listing 3
Listing 4
Sidebar 1

nov92.tar


Listing 3: mboxck

#!/bin/sh
#
# mboxck - look for large or old mailbox files
#
MAILSPOOL=/var/spool/mail       # mail spool directory
MAXSIZE=100                     # max size in 512 byte blocks
MAXAGE=30                       # max days since last access
#
HOST=`hostname`
TMP=/tmp/mboxck.$$
rm -f $TMP

if [ -f /vmunix ]; then         # get Berkeley df(1)
DFCOMMAND=/bin/df            # if SunOS
else
DFCOMMAND=/usr/ucb/df        # if SVR4
fi

cd $MAILSPOOL
if [ $? -ne 0 ]; then
echo "Cannot access $MAILSPOOL directory on $HOST"
exit
fi

#
# make sure the mail spool directory is physically on this host
#
x=`$DFCOMMAND . | grep "^/"`
if [ -z "$x" ]; then
echo "$MAILSPOOL directory not local to $HOST"
exit
fi

#
# make a list of the files that qualify
#

find * -type f -size +100 -o -atime +$MAXAGE -exec ls -l {} \; >$TMP

#
# report any results
#
n=`wc -l $TMP | awk '{print $1}'`
if [ $n -gt 0 ]; then
echo " "
echo "Old or large mailboxes on $HOST in $MAILSPOOL"
echo " "
sed 's/^/     /' $TMP
echo " "
fi

rm -f $TMP