1#!/bin/sh 2# 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 $ 5# 6# Perform temporary directory cleaning so that long-lived systems 7# don't end up with excessively old files there. 8# 9 10# If there is a global system configuration file, suck it in. 11# 12if [ -r /etc/defaults/periodic.conf ] 13then 14 . /etc/defaults/periodic.conf 15 source_periodic_confs 16fi 17 18case "$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:" 28 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'` 38 } 39 case "$daily_clean_tmps_verbose" in 40 [Yy][Ee][Ss]) 41 print=-print;; 42 *) 43 print=;; 44 esac 45 46 rc=$(for dir in $daily_clean_tmps_dirs 47 do 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;; 57 58 *) rc=0;; 59esac 60 61exit $rc 62