Created
July 26, 2018 12:23
-
-
Save cronfy/b39af40d98498702f8e21b0afffd71b7 to your computer and use it in GitHub Desktop.
Smoothly remove large number of files, by batches/sec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Удаляем по 20 файлов в секунду. За 3 часа плавно удалим 200k файлов. | |
# Пригодится, когда нужно обновить кеш картинок на сайте, но нельзя удалить сразу весь кеш, | |
# потому что сайт ляжет из-за генерации новых картинок. | |
find ./ -type f | while sleep 1 ; do | |
CNT=0 | |
while read line ; do | |
CNT=$(($CNT + 1)) | |
echo "$line" | |
[ "20" -le "$CNT" ] && break | |
done | xargs rm -v | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment