home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!caen!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!szatezal
- From: szatezal@magnus.acs.ohio-state.edu (Shane M Zatezalo)
- Subject: Script un-cron-able?
- Message-ID: <1993Jan4.195233.9414@magnus.acs.ohio-state.edu>
- Sender: news@magnus.acs.ohio-state.edu
- Nntp-Posting-Host: magnusug.magnus.acs.ohio-state.edu
- Organization: The Ohio State University
- Date: Mon, 4 Jan 1993 19:52:33 GMT
- Lines: 82
-
- Here's the story: I wrote this script for our NeXT's at work. (It is
- supposed to report a list of how much space each user is using up via
- their directories, and if its over a specified limit, mail a notice
- to them.) IF I run it, it runs fine. If I cron it, its output is fine,
- but sometimes its output is mailed to me 3-4 times when it should
- only be once.
- The weird thing is that this "mailing" problem is sporadic... sometimes
- it works fine, sometimes it doesn't... and sometimes, even though it
- is in the cron list (actually, crontab.local on our server) it seems
- like the script is never run because we receive no mail at all.
-
- BUT, it always works fine if I run it.
-
- So why can't I cron it? Please take a look at it. Hopefully, since it
- is very simple, it shouldn't need much more explanation than the above.
-
- #!/bin/sh
- #
- # User Directory Size Reporter
- # By Shane M. Zatezalo 12/18/92
- # Call TAP, a FutureNet BBS (614)297-7031 24/96/14.4/16.8/19.2 DSHST
- # Script description at the end....
- #
- LIMIT=10000
- USRDIR=/
- USRDIR2=/Users
- MAILTO="shane njh"
- MAILED=" "
- NOTICE="/usr/local/lib/email.notice"
- TMP=/tmp/diskspace.$$
- PMT=/tmp/ds.$$
- rm -f $TMP $PMT
- echo 'User Disk Space Report.' >> $TMP
- echo ' ' >> $TMP
- echo 'Part 1 - The /Users directory.' >> $TMP
- echo '-------------------------------' >> $TMP
- cd $USRDIR
- ls -s Users >> $TMP
- echo ' ' >> $TMP
- echo 'Part 2 - Space/User - Megs - Limit='$LIMIT >> $TMP
- echo '----------------------------------------' >> $TMP
- echo ' ' >> $TMP
- cd $USRDIR2
- ls -l | ~shane/bin/cut -c45-69 >> $PMT
- cat $PMT |
- while read line
- do
- name=`echo $line | awk '{print$1}'`
- if [ "$name" ]
- then
- MAILED=" "
- amount=`du -s "${name}" | awk '{print$1}'`
- if [ \( "$amount" -ge $LIMIT \) -a \( "$name" -ne "11000" \) ]
- then
- mail -i -s 'Your diskspace' $name < $NOTICE
- MAILED=" *** MAILED ***"
- fi
- echo "$name $amount $MAILED" >> $TMP
- fi
- done
- mail -i -s 'Hosers with huge user directories' $MAILTO < $TMP
- rm -f $TMP $PMT
- exit 0
- #
- # This script is supposed to make a report of the user's directory
- #size, and if its above the set limit, mail that user a polite
- #warning and suggestions on how to lower their disk space consumption.
- #
- # 3 things to note:
- # ls -l ; shane/bin/cut is the "normal" cut, not "cut" normally on NeXT's
- # we have a dir. called "11000", and we did not want that included in output
- # This /also/ does include the /Users directory, so you can see that
- # (which would be "report #1)
-
-
- Any help is appreciated. Thanks!
-
- ::::::::Apple II forever!!:::::::GO BUCKS!::::::::Play Lacrosse!!::::::::::
- : Shane M. Zatezalo : i-net> szatezal@magnus.acs.ohio-state.edu :
- : CIS Eng Ohio State : NeXTMail> shane@kiwi.swhs.ohio-state.edu :
- :GS::: call T.A.P. a Futurenet BBS 614-297-7031 16.8k DS HST 425 MEGS ::GS:
-
-