Rather than using both -prune (which requires directory-first tree traversal)
and -delete (which implies depth-first traversal), avoid using -delete in favour of -execdir. This has a side-effect of not removing directories that contain files, even if we delete all of those files, but IMHO that's a better option than specifying all possible local filesystem types in this script. PR: 122811 MFC after: 3 weeks
This commit is contained in:
parent
f4471727f3
commit
045e970615
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=193302
@ -29,7 +29,7 @@ case "$daily_clean_disks_enable" in
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Cleaning disks:"
|
echo "Cleaning disks:"
|
||||||
set -f noglob
|
set -f noglob
|
||||||
args="$args -name "`echo "$daily_clean_disks_files" |
|
args="-name "`echo "$daily_clean_disks_files" |
|
||||||
sed -e 's/^[ ]*//' \
|
sed -e 's/^[ ]*//' \
|
||||||
-e 's/[ ]*$//' \
|
-e 's/[ ]*$//' \
|
||||||
-e 's/[ ][ ]*/ -o -name /g'`
|
-e 's/[ ][ ]*/ -o -name /g'`
|
||||||
@ -41,9 +41,9 @@ case "$daily_clean_disks_enable" in
|
|||||||
print=;;
|
print=;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
rc=$(find / \( ! -fstype local -o -fstype rdonly \) -a -prune -o \
|
rc=$(find / \( ! -fstype local -o -fstype rdonly \) -prune -o \
|
||||||
\( $args \) -atime +$daily_clean_disks_days -delete $print |
|
\( $args \) -atime +$daily_clean_disks_days \
|
||||||
tee /dev/stderr | wc -l)
|
-execdir rm -df {} \; $print | tee /dev/stderr | wc -l)
|
||||||
[ -z "$print" ] && rc=0
|
[ -z "$print" ] && rc=0
|
||||||
[ $rc -gt 1 ] && rc=1
|
[ $rc -gt 1 ] && rc=1
|
||||||
set -f glob
|
set -f glob
|
||||||
|
Loading…
Reference in New Issue
Block a user