3 # $Header: cleantmps,v 1.14 97/07/24 12:17:34 root Exp $
6 # This is a shell script to clean up files that clutter the tmp directories
7 # and garbage files that take up a lot of space (e.g., core files).
10 # Clean up specific garbage files, old log files
12 find /tmp -mountstop -mtime +1 -name "sh[1-9]*.[1-9]*" -exec rm {} \;
13 find /tmp -mountstop -mtime +3 -name "*~" -exec rm {} \;
14 find /tmp -mountstop -mtime +3 -name "eXT*" -exec rm {} \;
15 find /tmp -mountstop -mtime +3 -name "clr*" -exec rm {} \;
16 find /var/tmp -mountstop -mtime +3 -name "*~" -exec rm {} \;
17 find /tmp -mountstop -mtime +7 -name "crout*" -exec rm {} \;
18 find /var/tmp -mountstop -mtime +7 -name "cscope[0-9]*" -exec rm {} \;
21 # Delete crash core dumps and kernel backups (leave behind INDEX (log) file)
23 find /var/adm/crash -type f -name "core.*" -exec rm {} \;
24 find /var/adm/crash -type f -name "vmunix*" -exec rm {} \;
27 # General aging of everything in /tmp
30 # Preserve sockets and certain files which I don't want to age away
31 find /tmp -mountstop -depth -mtime +7 ! -type d ! -type s ! -type p |
32 egrep -v "\.log$|\.X11-unix" | xargs -n25 rm
34 # Try to remove directories -- only empty ones will actually get removed.
35 find /tmp -mountstop -depth -type d ! -name lost+found -print |
36 xargs -i -n25 rmdir -f {} 2>/dev/null
39 # Search entire filesystem for files which are automatically cleaned up.
41 # Remove #* and core files. Exclude *.flc (emacs font-lock (fast-lock)
42 # files, which can start with '#').
44 find / \( -fsonly hfs -o -fsonly vxfs \) -mtime +3 -type f \
45 \( -name "#*" -o -name "core" \) ! -name "*.flc" | xargs rm -f
47 # PJJ NOTE ON THE ABOVE COMMAND:
49 # By including only hfs and vxfs filesystems, we avoid descending NFS or
51 # (ClearCase) mount points. We don't use "! -fstype nfs" -- that would
53 # descend NFS mounts, looking for HFS/VxFS mounted underneath. One could
54 # argue that it's preferable to do something like
56 # find / \( -fstype nfs -o -fstype mvfs \) -prune -o -mtime +3 ...
58 # (i.e., only list filesystem types to exclude), but the mention of mvfs
59 # would cause the command to fail on hosts which don't have ClearCase.