问题原文
原帖链接 · hyperknot · CC BY-SA 3.0
I'd like to delete an nginx cache directory, which I quickly purged by:
mv cache cache.bak
mkdir cache
service nginx restart
Now I have a cache.bak folder which has 2 million files. I'd like to delete it, without disturbing the server.
A simple rm -rf cache.bak trashes the server, even the simplest HTTP response takes 16 seconds while rm is running, so I cannot do that.
I tried ionice -c3 rm -rf cache.bak, but it didn't help. The server has an HDD, not an SSD, probably on an SSD these might not be a problem.
I believe the best solution would be some kind of throttling, like how nginx's built in cache manager does.
How would you solve this? Is there any tool which can do exactly this?
ext4 on Ubuntu 16.04
社区高分解答
原帖链接 · Alex · CC BY-SA 3.0
You should consider saving your cache on a separate filesystem that you can mount/unmount as someone stated in comments. Until you do, you can use this one liner /usr/bin/find /path/to/files/ -type f -print0 -exec sleep 0.2 \; -exec echo \; -delete assuming your find binary is located under /usr/bin and you want to see the progress on screen. Adjust the sleep accordingly, so you don't over stress your HDD.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
