cachecleanup.sh 559 B

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