There are over 1m+ cache files in one directory on a server. I would need to remove them, but of course rm
first lists file and then starts to remove them.
That cause a high spike in a server CPU load and can cause whole server to break down.
Any ideas how to safely remove them without causing any harm?
Asked
Active
Viewed 497 times
0

micjan
- 73
-
2see http://unix.stackexchange.com/q/37329 and http://unix.stackexchange.com/q/66806 – don_crissti Nov 05 '16 at 17:20
1 Answers
2
If you value more cpu usage than speed on the erase, this is a good approach:
find <dir> -type f -exec ionice -c3 rm {} \;
Replace \;
with +
if you want some more speed (and more cpu).

Jeff Schaller
- 67,283
- 35
- 116
- 255