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
19 cd /tmp ||
{ log_failure_msg
"bootclean: Could not cd to /tmp." ; return 1 ; }
21 [ "$(find . -maxdepth 0 -perm -002)" = "." ] ||
return 0
25 log_warning_msg
"Using default TMPTIME 0."
29 [ "$VERBOSE" = no
] || log_action_begin_msg
"Cleaning /tmp"
34 # Don't clean remaining files if TMPTIME is negative or 'infinite'
38 [ "$VERBOSE" = no
] || log_action_end_msg
0 "skipped"
48 TEXPR
="-mtime +$TMPTIME -ctime +$TMPTIME -atime +$TMPTIME"
49 DEXPR
="-mtime +$TMPTIME -ctime +$TMPTIME"
53 ! ( -path ./lost+found -uid 0 )
54 ! ( -path ./quota.user -uid 0 )
55 ! ( -path ./aquota.user -uid 0 )
56 ! ( -path ./quota.group -uid 0 )
57 ! ( -path ./aquota.group -uid 0 )
58 ! ( -path ./.journal -uid 0 )
59 ! ( -path ./.clean -uid 0 )
60 ! ( -path ./lost+found -uid 0 )
61 ! ( -path '.
/...security
*' -uid 0 )'
65 if [ "$VERBOSE" = no
]
67 log_failure_msg
"bootclean: Failure cleaning /tmp."
69 log_action_end_msg
1 "bootclean: Failure cleaning /tmp"
74 # First remove all old files...
75 # (Use xargs here so that only one additional process gets created)
77 find .
-depth -xdev $TEXPR $EXCEPT ! -type d \
78 -print0 |
xargs -0r rm -f -- \
79 ||
{ report_err
; return 1 ; }
82 # ...and then all empty directories
83 # (Don't use xargs here because dirs must be removed one by one from
86 find .
-depth -xdev $DEXPR $EXCEPT -type d
-empty \
88 ||
{ report_err
; return 1 ; }
90 [ "$VERBOSE" = no
] || log_action_end_msg
0