3 # Thu Mar 27 13:59:00 EDT 2008 docelic:
5 # Clean /tmp for files older than TMPTIME days. Basically the copy of
6 # /etc/init/bootclean's clean_tmp().
8 # How much files are kept is controlled by existing variable TMPTIME in
15 .
/lib
/lsb
/init-functions
17 cd /tmp ||
{ log_failure_msg
"bootclean: Could not cd to /tmp." ; return 1 ; }
19 [ "$(find . -maxdepth 0 -perm -002)" = "." ] ||
return 0
23 log_warning_msg
"Using default TMPTIME 0."
27 [ "$VERBOSE" = no
] || log_action_begin_msg
"Cleaning /tmp"
32 # Don't clean remaining files if TMPTIME is negative or 'infinite'
36 [ "$VERBOSE" = no
] || log_action_end_msg
0 "skipped"
46 TEXPR
="-mtime +$TMPTIME -ctime +$TMPTIME -atime +$TMPTIME"
47 DEXPR
="-mtime +$TMPTIME -ctime +$TMPTIME"
51 ! ( -path ./lost+found -uid 0 )
52 ! ( -path ./quota.user -uid 0 )
53 ! ( -path ./aquota.user -uid 0 )
54 ! ( -path ./quota.group -uid 0 )
55 ! ( -path ./aquota.group -uid 0 )
56 ! ( -path ./.journal -uid 0 )
57 ! ( -path ./.clean -uid 0 )
58 ! ( -path ./lost+found -uid 0 )
59 ! ( -path '.
/...security
*' -uid 0 )'
63 if [ "$VERBOSE" = no
]
65 log_failure_msg
"bootclean: Failure cleaning /tmp."
67 log_action_end_msg
1 "bootclean: Failure cleaning /tmp"
72 # First remove all old files...
73 # (Use xargs here so that only one additional process gets created)
75 find .
-depth -xdev $TEXPR $EXCEPT ! -type d \
76 -print0 |
xargs -0r rm -f -- \
77 ||
{ report_err
; return 1 ; }
80 # ...and then all empty directories
81 # (Don't use xargs here because dirs must be removed one by one from
84 find .
-depth -xdev $DEXPR $EXCEPT -type d
-empty \
86 ||
{ report_err
; return 1 ; }
88 [ "$VERBOSE" = no
] || log_action_end_msg
0