Date: Mon, 4 Mar 2002 14:11:54 -0600 (CST) From: D J Hawkey Jr <hawkeyd@visi.com> To: FreeBSD-gnats-submit@freebsd.org Subject: conf/35545: Enhanced periodic scripts Message-ID: <200203042011.g24KBsv55481@sheol.localdomain>
next in thread | raw e-mail | index | archive | help
>Number: 35545 >Category: conf >Synopsis: Enhanced periodic scripts >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 04 12:20:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: David J Hawkey Jr \<hawkeyd@visi.com\> >Release: FreeBSD 4.5-RELEASE i386 >Organization: if (!FIFO) if (!LIFO) break; >Environment: System: FreeBSD sheol.localdomain 4.5-RELEASE FreeBSD 4.5-RELEASE #2: Mon Feb 11 09:18:49 CST 2002 root@sheol.localdomain:/usr/src/sys/compile/SHEOL i386 >Description: /etc/periodic/daily/100.clean-disks should have "exclude paths". /etc/periodic/daily/110.clean-tmps removes empty directories, and should not, IMHO. >How-To-Repeat: Enable either in /etc/periodic.conf >Fix: These two patches. The first, for 100.clean-disks, honors a new variable, daily_clean_disks_excludes (ex., "*/home/*"). The second, for 110.clean-tmps, honors a new variable, daily_clean_tmps_prune (ex., "YES" or "NO"). Additionally, they both actually make their *_verbose variables do the Right Thing(tm), and could pro'lly be applied to many more of the periodic scripts. They both should be scrutinized for correctness. They test out fine here, and fulfill my needs, but may not be generic enough, and I may be blind to some nuances of 'find' and/or 'periodic'. --- 100.clean-disks.orig Mon Jan 28 07:13:17 2002 +++ 100.clean-disks Mon Mar 4 13:18:35 2002 @@ -33,6 +33,12 @@ sed -e 's/^[ ]*//' \ -e 's/[ ]*$//' \ -e 's/[ ][ ]*/ -o -name /g'` + [ -n "$daily_clean_disks_excludes" ] && + excl="$excl ! -path "`echo "$daily_clean_disks_excludes" | + sed -e 's/^[ ]*//' \ + -e 's/[ ]*$//' \ + -e 's/[ ][ ]*/ -a ! -path /g'` && + excl="( $excl ) -a" case "$daily_clean_disks_verbose" in [Yy][Ee][Ss]) @@ -41,9 +47,21 @@ print=;; esac + # $print is currently meaningless, but retained for if + # and when 'find' without "-print" actually inhibits output. + # $out is a hack until then. + + out=/var/run/_100_clean-disks_out.$$ rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \ - \( $args \) -atime +$daily_clean_disks_days -delete $print | - tee /dev/stderr | wc -l) + $excl \( $args \) -atime +$daily_clean_disks_days \ + -delete $print | tee $out | wc -l) + if [ -n "$print" ] + then + cat $out + else + echo " (output inhibited)" + fi + rm -f $out [ -z "$print" ] && rc=0 [ $rc -gt 1 ] && rc=1 set -f glob --- 110.clean-tmps.orig Mon Jan 28 07:13:17 2002 +++ 110.clean-tmps Mon Mar 4 12:00:53 2002 @@ -36,15 +36,40 @@ *) print=;; esac + case "$daily_clean_tmps_prune" in + [Yy][Ee][Ss]) + delete=-delete;; + *) + delete=;; + esac + # $print is currently meaningless, but retained for if + # and when 'find' without "-print" actually inhibits output. + # $out is a hack until then. + + out=/var/run/_110_clean_tmps_out.$$ + tmp=/var/run/_110_clean_tmps_tmp.$$ rc=$(for dir in $daily_clean_tmps_dirs do [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && { find -d . -type f $args -delete $print find -d . ! -name . -type d -empty -mtime \ - +$daily_clean_tmps_days -delete $print + +$daily_clean_tmps_days $delete $print > $tmp + if [ -s $tmp ]; then + echo -n " Empty directories" + [ -n "$delete" ] && echo -n " removed" + echo ":" + sed "s,^\\., $dir," $tmp + fi } | sed "s,^\\., $dir," - done | tee /dev/stderr | wc -l) + done | tee $out | wc -l) + if [ -n "$print" ] + then + cat $out + else + echo " (output inhibited)" + fi + rm -f $out $tmp [ -z "$print" ] && rc=0 [ $rc -gt 1 ] && rc=1 set -f glob >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203042011.g24KBsv55481>