02/10/2015

Efficient and quick way to delete files! - Bash

On the sidelines of previous post "An efficient and quick way to search with find, grep, and xargs", I've just remembered one of servers has an issue with sessions garbage collection! So, after a while the monitoring system detected unusual decrease in free disk space. And after I got a look, I found sessions directory has about 32 million file :D

As I mentioned in the other post, normal tools aren't designed to work with huge number of files like that, so to deal with this especially in regard to "disk IO" and "CPU utilization" in production environment, "find" was the best solution to delete that huge number of files.

Actually, this time you will not need an external command like "rm" or so, "find" itself has an option called "-delete", which can be used to delete files:
find PATH -type f -name "FILES_PATTERN" -delete
That's why I love "find", it's very powerful and has many great options. It always save my time, I did a lot of cool things just with find!
Powered by Blogger.

Hello, my name is Ahmed AbouZaid, I'm a passionate Tech Lead DevOps Engineer. 👋

I specialize in Cloud-Native and Kubernetes. I'm also a Free/Open source geek and book author. My favorite topics are DevOps transformation, DevSecOps, automation, data, and metrics.

More about me ➡️

Contact Me

Name

Email *

Message *

Start Your DevOps Engineer Journey!

Start Your DevOps Engineer Journey!
Start your DevOps career for free the Agile way in 2024 with the Dynamic DevOps Roadmap ⭐

Latest Post

Research Paper: Building a Modern Data Platform Based on the Data Lakehouse Architecture and Cloud-Native Ecosystem

Finally, after months of hard work, I have published my first research paper in a double-blind peer-reviewed scientific journal by the in...

Popular Posts

Blog Archive