1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#!/bin/bash
# cache directory cleanup script example
#
# removes all old cached files with mtime older than index mtime
#
# there MUST be your ACTUAL index names and FULL PATHS to indexfiles
indexnames=( test1 test2 )
indexfiles=( /usr/local/sphinx/test1.spd /benchmarks/work/test/test2.spd )
cachedir=/tmp/cache
for element in $(seq 0 $((${#indexnames[@]} - 1)))
do
echo "processing index ${indexnames[$element]}"
find "$cachedir/${indexnames[$element]}" \( ! -newer "${indexfiles[$element]}" \) -type f -print0 | xargs -0 -r rm -f
done
|