home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume3 / clr.queue < prev    next >
Text File  |  1986-11-30  |  2KB  |  89 lines

  1. Subject: sendmail clean-up script
  2. From: David Barto <genrad!celerity!barto>
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 3, Issue 43
  7. Submitted by: David Barto <ihnp4!bang!celerity!barto>
  8.  
  9.  
  10. : feed me to sh
  11. cat > INFO <<'end-INFO'
  12. The following is a script to track and mail to ADMIN the
  13. clean up of the sendmail queue.  This clears invalid files,
  14. moves out the wedged mail and sends a report to the administrator
  15. listed in ADMIN.
  16.  
  17. I have been using it for about 3 months without problems, and It
  18. lets me know how well the local area network moves its mail.
  19.  
  20. I install it as /usr/adm/clr.queue, and have cron run it once
  21. a nite at about 2am.  (low active user count).
  22. end-INFO
  23. cat > clr.queue <<'end-clr.queue'
  24. #! /bin/csh -f
  25. # clear the sendmail queue of any waiting mail
  26. #
  27. set ADMIN = barto
  28. set mqueue = /usr/spool/mqueue
  29. set output = /tmp/clr.out$$
  30.  
  31. cat /dev/null > $output
  32.  
  33. cd $mqueue
  34.  
  35. foreach f (*)
  36.     switch ($f)
  37.         case 'syslog*':    # skip log files
  38.             breaksw;
  39.         case 'df*':
  40.             set qf = `echo $f | sed -e 's/df/qf/' `
  41.             if (! -e $qf) then
  42.                 echo "Missing qf file for $f" >> $output
  43.                 echo "Contents of $f follow:" >> $output
  44.                 cat $f >> $output
  45.                 echo "---- end of $f" >> $output
  46.                 echo "/bin/rm -f $f" >> $output
  47.                 /bin/rm -f $f
  48.             else if (-z $f) then
  49.                 echo "$f is empty, deleted" >> $output
  50.                 /bin/rm -f $f
  51.             endif
  52.             breaksw
  53.  
  54.         case 'xf*':
  55.         case 'lf*':
  56.             echo /bin/rm $f >> $output
  57.             /bin/rm $f
  58.             breaksw
  59.  
  60.         case 'qf*':
  61.             set df = `echo $f | sed -e 's/qf/df/' `
  62.             if (! -e $df) then
  63.                 echo "Missing df file for $f" >> $output
  64.                 echo "Contents of $f follow:" >> $output
  65.                 cat $f >> $output
  66.                 echo "---- end of $f" >> $output
  67.                 echo /bin/rm $f >> $output
  68.                 /bin/rm $f
  69.             endif
  70.             breaksw
  71.         
  72.         default:
  73.             echo "Invalid file $f, deleted" >> $output
  74.             /bin/rm -f $f
  75.             breaksw
  76.     endsw
  77. end
  78.  
  79. /usr/lib/sendmail -q -v >> $output
  80.  
  81. if (! -z $output) then
  82.     Mail -s "Sendmail Cleanup" $ADMIN < $output
  83. endif
  84.  
  85. /bin/rm $output
  86. end-clr.queue
  87. exit
  88.  
  89.