Mac Performance

Mac Maintenance Tasks You Should Run Regularly

From flushing DNS to rebuilding Spotlight — the maintenance tasks that keep your Mac running smoothly and how to perform them safely.

Modern macOS is largely self-maintaining, but there are situations where manual intervention helps. Here are the maintenance tasks worth knowing about, when to run them, and how.

Flush DNS cache

When: After changing DNS servers, when websites aren't loading despite having internet connectivity, or after modifying your hosts file.

Your Mac caches DNS lookups to speed up browsing. Sometimes this cache becomes stale or corrupted, causing websites to fail loading or resolving to wrong IP addresses.

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

This is completely safe and takes effect immediately. Your Mac will simply re-resolve domain names on the next request.

Clear Quick Look cache

When: File thumbnails and previews look wrong, broken, or show outdated content.

Quick Look generates and caches thumbnails and previews for files. If these get corrupted, you'll see incorrect previews in Finder, incorrect thumbnails in Cover Flow, or broken previews when pressing Space on a file.

qlmanage -r cache

Quick Look will regenerate thumbnails on demand after clearing.

Reset Launch Services

When: The "Open With" context menu shows duplicate apps, incorrect app associations, or apps that have been uninstalled.

Launch Services maintains the database of which apps can open which file types. It can become confused after installing, updating, or removing apps.

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

This command rebuilds the entire database. It takes a minute or two and temporarily makes the "Open With" menu slower while it repopulates.

Restart Finder, Dock, and Menu Bar

When: Finder is behaving strangely (not showing files, drag-and-drop broken), the Dock isn't responding, or menu bar icons are missing/stuck.

These are lightweight restarts that take a second:

killall Finder      # Finder auto-relaunches
killall Dock        # Dock auto-relaunches
killall SystemUIServer  # Menu bar auto-relaunches

These are harmless and solve most UI glitches instantly.

Rebuild Spotlight index

When: Search returns incomplete or missing results, Spotlight is slow, or after a major macOS update.

sudo mdutil -E /

Reindexing can take 30 minutes to several hours. Your Mac will use more CPU during this time, so it's best to do this when you don't need peak performance.

View Time Machine snapshots

When: Your drive is running low on space and you suspect local Time Machine snapshots are consuming storage.

macOS creates local Time Machine snapshots even when your backup drive isn't connected. These are usually managed automatically, but sometimes they accumulate:

tmutil listlocalsnapshots /

If you see many snapshots and need the space, Time Machine will eventually thin them out, or you can delete specific ones.

Enable Touch ID for sudo

When: You're tired of typing your password for Terminal commands that require sudo.

This is a one-time setup that lets you use your fingerprint for sudo authentication:

sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local
sudo sed -i '' 's/^#auth/auth/' /etc/pam.d/sudo_local

How often should you do this?

Most of these tasks are reactive — you run them when something isn't working right. There's no need to flush DNS daily or rebuild Spotlight weekly. The exceptions are:

  • Quick Look cache — Worth clearing every few months if you notice preview issues
  • Launch Services — Clear after major app installs or removals

CleanMyMacOS provides all 9 of these maintenance tasks with guided commands. Each task shows the exact command, explains what it does, and indicates the risk level. For Finder, which can be restarted safely from within the sandbox, the app handles it directly. For commands requiring admin privileges, it shows the command for you to copy and run in Terminal.

CleanMyMacOS can help with this — download it free from the Mac App Store.