freebsd-dev/etc/periodic/daily/110.clean-tmps
Brian Somers 008c5376df Use $clear_daily_* from rc.conf to decide what should be deleted
Reviewed by:	The silence of -committers
2000-06-09 17:05:11 +00:00

50 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
#
# $FreeBSD$
#
# Perform temporary directory cleaning so that long-lived systems
# don't end up with excessively old files there. If /var/tmp and
# /tmp are symlinked together, only one of the below will actually
# run.
#
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
case "$clear_daily_enable" in
[Yy][Ee][Ss])
if [ -n "$clear_daily_days" ]
then
echo ""
echo "Removing old temporary files:"
set -f noglob
args="-atime +$clear_daily_days -mtime +$clear_daily_days"
[ -n "$clear_daily_ignore" ] &&
args="$args "`echo " ${clear_daily_ignore% }" |
sed 's/[ ][ ]*/ ! -name /g'`
case "$clear_daily_verbose" in
[Yy][Ee][Ss])
print=-print;;
*)
print=;;
esac
for dir in $clear_daily_dirs
do
[ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && {
find -d . -type f $args -delete $print
find -d . ! -name . -type d -mtime +$clear_daily_days \
-delete $print
} | sed "s,^\\., $dir,"
done
set -f glob
fi;;
esac