MFC: Use humanize_number(3) for -h and -H.
[dragonfly.git] / etc / periodic / daily / 110.clean-tmps
blob1643afe3a2af3d3fa564c173cd2ccabad18faf7e
1 #!/bin/sh
3 # $FreeBSD: src/etc/periodic/daily/110.clean-tmps,v 1.13 2004/02/28 04:58:40 ache Exp $
4 # $DragonFly: src/etc/periodic/daily/110.clean-tmps,v 1.3 2007/12/29 21:44:44 matthias Exp $
6 # Perform temporary directory cleaning so that long-lived systems
7 # don't end up with excessively old files there.
10 # If there is a global system configuration file, suck it in.
12 if [ -r /etc/defaults/periodic.conf ]
13 then
14 . /etc/defaults/periodic.conf
15 source_periodic_confs
18 case "$daily_clean_tmps_enable" in
19 [Yy][Ee][Ss])
20 if [ -z "$daily_clean_tmps_days" ]
21 then
22 echo '$daily_clean_tmps_enable is set but' \
23 '$daily_clean_tmps_days is not'
24 rc=2
25 else
26 echo ""
27 echo "Removing old temporary files:"
29 set -f noglob
30 args="-atime +$daily_clean_tmps_days -mtime +$daily_clean_tmps_days"
31 args="${args} -ctime +$daily_clean_tmps_days"
32 dargs="-empty -mtime +$daily_clean_tmps_days"
33 [ -n "$daily_clean_tmps_ignore" ] && {
34 args="$args "`echo " ${daily_clean_tmps_ignore% }" |
35 sed 's/[ ][ ]*/ ! -name /g'`
36 dargs="$dargs "`echo " ${daily_clean_tmps_ignore% }" |
37 sed 's/[ ][ ]*/ ! -name /g'`
39 case "$daily_clean_tmps_verbose" in
40 [Yy][Ee][Ss])
41 print=-print;;
43 print=;;
44 esac
46 rc=$(for dir in $daily_clean_tmps_dirs
48 [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && {
49 find -d . -type f $args -delete $print
50 find -d . ! -name . -type d $dargs -delete $print
51 } | sed "s,^\\., $dir,"
52 done | tee /dev/stderr | wc -l)
53 [ -z "$print" ] && rc=0
54 [ $rc -gt 1 ] && rc=1
55 set -f glob
56 fi;;
58 *) rc=0;;
59 esac
61 exit $rc