From owner-freebsd-questions Wed Jun 19 8:22:33 2002 Delivered-To: freebsd-questions@freebsd.org Received: from snipe.mail.pas.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62]) by hub.freebsd.org (Postfix) with ESMTP id 3D07137B405 for ; Wed, 19 Jun 2002 08:22:25 -0700 (PDT) Received: from user-119a2km.biz.mindspring.com ([66.149.10.150] helo=scee.dsj.net) by snipe.mail.pas.earthlink.net with esmtp (Exim 3.33 #2) id 17KhHq-0004Xk-00; Wed, 19 Jun 2002 08:22:22 -0700 Received: from dsj by scee.dsj.net with local (Exim 3.35 #1 (Debian)) id 17Kgye-0005LP-00; Wed, 19 Jun 2002 11:02:32 -0400 Date: Wed, 19 Jun 2002 11:02:09 -0400 From: "David S. Jackson" To: Steven Lake Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Determining # of mail's per user Message-ID: <20020619150205.GC6184@scee.dsj.net> Reply-To: "David S. Jackson" References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.28i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Jun 16, 2002 at 03:33:51PM -0500 Steven Lake wrote: > What's the easiest way to determin how many emails a given user > has on the mail server? I understand you already found a solution, but you might have a look at from. Not sure if it's in the standard installation or the ports tree. You might also look at newmail, which I think is in the ports tree. > I need to generate a list of how many emails and > how much space each mail file is taking up per user. ocd /var/mail; Something like this should help... #!/usr/local/bin/bash maildir=/var/mail # or wherever yours is maxsize=1234 # decide on acceptable mailbox size... maxnum=100 # maxnumber of emails allowed message="Your email mailbox size has exceeded $maxsize. Your number of emails has exceeded $maxnum. Please delete emails until your mailbox size is less than $maxsize." domain="yourdomain.net" cd $maildir for i in *; do temp=/tmp/mailmessage.$i.txt size=`ls -sk $i | cut -d' ' -f1` num=`grep 'From:' $i | wc -l` if [ $size -gt $maxsize -o $num -gt $maxnum ]; then cat >> $temp < I'm having a space > problem on one of the mail servers and I want to create a simple formatted > output that I can put into a spreadsheet program and view who are the > biggest offenders. I could do it by mail file sizes, but to the less > experienced telling them they have 150 megs of email on the server doesn't > make as big an impact as saying they have 25,000 emails just sitting there > idle and taking up space. Plus it gives me some tangeble numbers to put > in the records. forspreadsheet=/tmp/spreadsheet.$$ if [ -e $forspreadsheet -a -w $spreadsheet ]; then rm $forspreadsheet fi cd $maildir for i in *; do size=`du $i | cut -d' ' -f1` num=`grep 'From:' $i | wc -l` line=`echo -e $i\t$num\t$size\n` cat $line >> $forspreadsheet done > There's also the fact that some users recieve large files on a > regular basis but are good about checking their mail and cleaning it out > regularly, so I don't want to punish them while punishing the true > offenders. Anyone got any good suggestions for me? The first script above checks for $size being greater than $maxsize before sending out an email. -- David S. Jackson dsj@dsj.net =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= I have a map of the United States. It's actual size. I spent last summer folding it. People ask me where I live, and I say, "E6". -- Steven Wright To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message