0

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?

micjan
  • 73

1 Answers1

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