Script to run deeper maintenance

I have long been a fan of Onyx, though prefer to be a bit more DIY with system cleaning and optimising. So I wrote a Bash script that I am trying to improve for Sierra / High Sierra. Currently I manually clear user and system caches, and reset my profile Firefox once a week - that has a major impact on making my mac more boxfresh.


Any hints of additional commands, better scripting and places to clean would be awesome...?


#!/bin/bash

# rebuild XPC caches

sudo /usr/libexec/xpchelper --rebuild-cache

# rebuild CoreDuet

sudo rm -fr /var/db/coreduet/*

# rebuild Launch Services

sudo /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchS ervices.framework/Versions/A/Support/lsregister -kill -r -seed -domain local -domain system -domain user

# Flush DNS cache and restart mdns

sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder

# clear BootCache

sudo rm -f /private/var/db/BootCache.playlist

# update Dyld cache

sudo update_dyld_shared_cache -root / -force

# rebuild Kernel extension caches

sudo touch /System/Library/Extensions && sudo kextcache -u /

# run system scripts

sudo periodic daily weekly monthly


The version I use also has echo statements and &> pipes to /dev/null


Thanks!!

MacBook Air, macOS High Sierra (10.13.4)

Posted on May 12, 2018 11:49 PM

Reply

Similar questions

6 replies

May 13, 2018 9:30 AM in response to Jonny S

Constantly clearing cache data is a waste of time. Your Mac will run slower until it has had time to rebuild the cache data, which is used to speed things up by accessing the cache for frequently used data.


Does it hurt anything to clear the cache? No, but unless you are actually having an issue that would be resolved specifically by clearing the cache, it also doesn't help.

May 14, 2018 3:11 PM in response to Jonny S

Just reboot your Mac occasionally when you want it to clear out the cache and temp files that are not needed. Those that don't need to be cleaned out will be retained.


The reason we've jumped in and given recommendations like we have is that we don't like to see users going off in the wrong direction away from good Mac computing practices. The same goes with our recommending to never use a "cleaning", "optimizing", "speed up" or antivirus app on your Mac, like Clean My Mac or MacKeeper or the many A/V apps as they are just not needed and do more harm to the system performance than good.


User uploaded file

May 14, 2018 9:35 PM in response to Old Toad

I've been using macs for over 20 years and have a relavetively deep understanding of both BSD and MacOS. I am also running on an i7 with SSD drives. Caches are rebuilt the first time you reboot and start an app - probably adding 1-2 seconds... it simply is not true that a machine that has been heavily used over a period gets faster because of caching, compared to a fresh install. The number 1 issue I deal with with macs is performance - every machine I run this script on is from a user POV, magically fixed.


The question is not a debate on whether to build up caches and boot occasionally. Franking I will disagree with you, so it is not a useful dialogue.


The question was where else can be cleared or rebuilt? If you think a quick reboot or never touching your machine is the solution, thank you - I think that has been discussed.


So does any one have any thoughts on the question?


Thanks

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Script to run deeper maintenance

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.