MacBook – ny program to delete cache files automatically

automationmacbook pro

Every time I need to clear cache, I have to go inside each folder and delete the contents. Doing it via terminal deletes the whole folder which is not recommended. What shall I do?

Best Answer

For so many questions like this, I feel folks are answering without asking what the poster's intention is.

Why do you want to delete the cache files automatically? It's generally a bad idea to do so.

I've seen so many questions posted where folks want to delete some system application or cache or configuration file or whatever. This just leads to the point where the OS must be reinstalled or the user complains that the machine is unstable/unreliable and someone must spend hours, days or months trying to diagnose something that never should have been tampered with.

macOS, in particular, is NOT Windows. You do NOT need to purge caches, defragment or whatever. If you're doing that, especially if you're doing that on a regular basis, there's a deeper problem.

I'm writing this response on a MacBook Pro that has not had any explicit maintenance performed since El Capitan; I'm now running the latest Mojave having upgraded dozens of times. I do software development, generally have a ton of Docker containers and Parallels VM's going and do a lot of video editing with FCP X/Motion. I have had extremely few problems and zero crashes across several years of use. Performance is wonderful.

Part of this is because I don't wake up in the morning and, on a whim, decide to delete my cache files, manually edit my partition table or delete key services like Safari.

As I write this response, I see posts about things like "Firefox freezes when I delete cache files and cookies" and "How do I restore an accidentally deleted key chain". Call me stupid AF, but why on Earth are you tempting fate?

All software makes many assumptions about its underpinnings. Nobody can write code that accounts for every possibility. I know I'm deep in rant territory, but you shouldn't be deleting cache files unless you're intimately familiar every line of code that uses those cache files, directly or indirectly. I assure you that neither Apple nor Microsoft have tested that their software functions correctly if some or all of the system cache files disappear...in fact, having an inconsistent set of cache files because you deleted some of them but didn't even know about all of them is precisely how you get into trouble.

And if you still feel the need to muck around under the hood, PLEASE back up religiously. One day you're going to goof and do a "sudo rm -rf /" or create some inconsistency that can't easily be fixed.

Just consider...Humpty Dumpty was pushed...