source: trunk/packs/maint/clean_tmp_areas.sh @ 10130

Revision 10130, 2.0 KB checked in by danw, 27 years ago (diff)
use -depth so we successfully rm empty directory trees
  • Property svn:executable set to *
Line 
1#!/bin/athena/tcsh -f
2#
3# This script is intended to replace the following "finds" which were
4#       intended to clean up /tmp, /usr/tmp and some other areas.
5#
6#       $Source: /afs/dev.mit.edu/source/repository/packs/maint/clean_tmp_areas.sh,v $
7#       $Author: danw $
8#       $Header: /afs/dev.mit.edu/source/repository/packs/maint/clean_tmp_areas.sh,v 1.8 1997-06-03 22:45:08 danw Exp $
9#
10# 05 1 * * *    root    find /tmp -atime +1 -exec rm -f {} \;
11# 10 1 * * *    root    cd /tmp; find . ! -name . -type d -mtime +1 -exec rm -r {} \;
12# 15 1 * * *    root    find /usr/tmp -atime +2 -exec rm -f {} \;
13# 20 1 * * *    root    cd /usr/tmp; find . ! -name . -type d -mtime +1 -exec rmdir {} \;
14# 10 4 * * *    root    (cd /usr/spool/rwho; find . -name whod.\* -mtime +7 -exec rm -f {} \;)
15# 15 4 * * *    root    (cd /usr/preserve; find . -mtime +7 -a -exec rm -f {} \;)
16#
17# It was discovered that on systems which do not have a /usr/tmp, and are
18#       idle much of the time, such as VS2 workstations, the "05 1" & "10 1"
19#       lines will delete everything in /tmp.  This allows the "20 1" line
20#       to delete /tmp, since there is no /usr/tmp.  This allows "10 1" to
21#       delete EVERYTHING on the disk which has not been accessed in 24
22#       hours.  AAAAAAAARRRRRRRRGGGGGGGGHHHHHHHH!!!!!!!! From Berkeley.
23set dirs =    ( /tmp/           /usr/tmp/       /usr/spool/rwho/ \
24                /usr/preserve/)
25set timeout = ( "-atime +1"     "-atime +2"     "-mtime +3" \
26                "-mtime +3")
27
28set xdev = -mount
29set exceptions = "! -type b ! -type c"
30
31switch($hosttype)
32        case sun4:
33                set exceptions = "$exceptions ! -type p ! -name ps_data"
34                breaksw
35        case sgi:
36                set exceptions = "$exceptions ! -type p ! -type s ! -user root"
37#                       ! -type s ! -name .ps_data ! -name .cadmin*
38#                       set noglob (for .cadmin*)
39                breaksw
40        case decmips:
41                set exceptions = "$exceptions ! -type s"
42                breaksw
43        case rsaix:
44                set exceptions = "$exceptions ! -type s"
45                set xdev = -xdev
46                breaksw
47        default:
48endsw
49
50set j = 1
51foreach i ($dirs)
52        if ( -d $i ) then
53                cd $i
54                find . $xdev $timeout[$j] $exceptions -exec rm -f {} \; -print
55                find . $xdev -depth ! -name . -type d -mtime +1 -exec rmdir {} \; -print
56        endif
57@ j++
58end     
Note: See TracBrowser for help on using the repository browser.