home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / question / 15155 < prev    next >
Encoding:
Text File  |  1993-01-04  |  3.3 KB  |  94 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!caen!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!szatezal
  3. From: szatezal@magnus.acs.ohio-state.edu (Shane M Zatezalo)
  4. Subject: Script un-cron-able?
  5. Message-ID: <1993Jan4.195233.9414@magnus.acs.ohio-state.edu>
  6. Sender: news@magnus.acs.ohio-state.edu
  7. Nntp-Posting-Host: magnusug.magnus.acs.ohio-state.edu
  8. Organization: The Ohio State University
  9. Date: Mon, 4 Jan 1993 19:52:33 GMT
  10. Lines: 82
  11.  
  12. Here's the story: I wrote this script for our NeXT's at work. (It is
  13. supposed to report a list of how much space each user is using up via
  14. their directories, and if its over a specified limit, mail a notice
  15. to them.) IF I run it, it runs fine. If I cron it, its output is fine,
  16. but sometimes its output is mailed to me 3-4 times when it should
  17. only be once.
  18. The weird thing is that this "mailing" problem is sporadic... sometimes
  19. it works fine, sometimes it doesn't... and sometimes, even though it
  20. is in the cron list (actually, crontab.local on our server) it seems
  21. like the script is never run because we receive no mail at all.
  22.  
  23. BUT, it always works fine if I run it.
  24.  
  25. So why can't I cron it? Please take a look at it. Hopefully, since it
  26. is very simple, it shouldn't need much more explanation than the above.
  27.  
  28. #!/bin/sh
  29. #
  30. # User Directory Size Reporter 
  31. # By Shane M. Zatezalo 12/18/92
  32. # Call TAP, a FutureNet BBS (614)297-7031 24/96/14.4/16.8/19.2 DSHST
  33. # Script description at the end....
  34. #
  35. LIMIT=10000
  36. USRDIR=/
  37. USRDIR2=/Users
  38. MAILTO="shane njh"
  39. MAILED=" "
  40. NOTICE="/usr/local/lib/email.notice"
  41. TMP=/tmp/diskspace.$$
  42. PMT=/tmp/ds.$$
  43. rm -f $TMP $PMT
  44. echo 'User Disk Space Report.' >> $TMP
  45. echo ' ' >> $TMP
  46. echo 'Part 1 - The /Users directory.' >> $TMP
  47. echo '-------------------------------' >> $TMP
  48. cd $USRDIR
  49. ls -s Users >> $TMP
  50. echo ' ' >> $TMP
  51. echo 'Part 2 - Space/User - Megs - Limit='$LIMIT >> $TMP
  52. echo '----------------------------------------' >> $TMP
  53. echo ' ' >> $TMP
  54. cd $USRDIR2
  55. ls -l | ~shane/bin/cut -c45-69 >> $PMT
  56. cat $PMT |
  57. while read line
  58. do
  59.         name=`echo $line | awk '{print$1}'`
  60.         if [ "$name" ]
  61.         then
  62.                 MAILED=" "
  63.                 amount=`du -s "${name}" | awk '{print$1}'`
  64.                 if [ \( "$amount" -ge $LIMIT \) -a \( "$name" -ne "11000" \) ]
  65.                 then
  66.                         mail -i -s 'Your diskspace' $name < $NOTICE
  67.                         MAILED=" *** MAILED ***"
  68.                 fi
  69.                 echo "$name $amount $MAILED" >> $TMP
  70.         fi
  71. done
  72. mail -i -s 'Hosers with huge user directories' $MAILTO < $TMP
  73. rm -f $TMP $PMT
  74. exit 0
  75. #
  76. # This script is supposed to make a report of the user's directory
  77. #size, and if its above the set limit, mail that user a polite
  78. #warning and suggestions on how to lower their disk space consumption.
  79. #
  80. # 3 things to note:
  81. # ls -l ; shane/bin/cut is the "normal" cut, not "cut" normally on NeXT's
  82. # we have a dir. called "11000", and we did not want that included in output
  83. # This /also/ does include the /Users directory, so you can see that
  84. # (which would be "report #1)
  85.  
  86.  
  87. Any help is appreciated. Thanks!
  88.  
  89. ::::::::Apple II forever!!:::::::GO BUCKS!::::::::Play Lacrosse!!::::::::::
  90. :   Shane M. Zatezalo         : i-net> szatezal@magnus.acs.ohio-state.edu :
  91. :   CIS Eng Ohio State        : NeXTMail>  shane@kiwi.swhs.ohio-state.edu :
  92. :GS::: call T.A.P. a Futurenet BBS 614-297-7031 16.8k DS HST 425 MEGS ::GS:
  93.  
  94.