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. 👋

With 16+ years of open-source contributions, 12+ years of hands-on experience in DevOps, and an M.Sc. in Data Engineering from Edinburgh Napier University (UK), I enjoy facilitating the growth of both businesses and individuals.

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

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

2023 Highlights

Image generated with Craiyon . Finally, 2023 is over! What a year! One more crazy year, but it was the culmination ...

Popular Posts

Blog Archive