keep files for one month

This commit is contained in:
z4yx 2020-03-23 09:12:33 +08:00
parent bad8003b0e
commit 30e447f18f

View File

@ -37,7 +37,7 @@ do
if [[ -f "$remote_filelist" ]];then # clean outdated files
local_filelist=/tmp/filelist.local
(cd ${HOMEBREW_CACHE}; find . -type f -iname "*.tmp" -delete)
(cd ${HOMEBREW_CACHE}; find . -type f -iname "*.tar.gz") | sed 's+^\./++' > $local_filelist
(cd ${HOMEBREW_CACHE}; find . -type f -mtime 30 -iname "*.tar.gz") | sed 's+^\./++' > $local_filelist
comm <(sort $remote_filelist) <(sort $local_filelist) -13 | while read file; do
echo "deleting ${HOMEBREW_CACHE}/${file}"
rm "${HOMEBREW_CACHE}/${file}"