How to delete thousands of files
Let's say we have a folder containing millions of small files, images, temporary files or the like that we want to delete to regain valuable resources. Using a simple
rm -rf folder may take a lot of time and use up 100% disk and CPU resources.
We could use the rsync command to works around the problem.
You must first create an empty folder ...
It is then possible to synchronize the 2 folders.
ionice -c 3 nice -19 rsync -a --delete empty/ folder/
This will then delete all the contents of the folder