Answer the question
In order to leave comments, you need to log in
How to delete files in Linux without slowing down the computer?
Due to crooked settings, a folder with several million files was formed.
Rm -rf of course deletes it, but the web server on the same computer is wildly stupid at the same time periodically falling into a 502 error.
And it would be fine if it was deleted quickly, but in 15 minutes the deletion process did not even think to end.
Is there any way to delete it in the background without rebooting the computer?
Answer the question
In order to leave comments, you need to log in
These questions have been studied for a long time and here are a couple of articles on Habré, there are almost all known solutions, read:
Unusual hard disk overflow or how to remove it ...
So how do you delete millions of files from one folder?
If files are cleaned on a regular basis, then it makes sense to make this folder a disk and connect it via fstab. For cleaning - umount + mkfs + mount. Takes seconds.
Also, pay attention to the file system type. For example zfs deletes slowly. Might be worth switching to ext4.
As an option - make a script that will delete one file at a time and pause.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question