Skip to content

Instantly share code, notes, and snippets.

@montj2
Created August 22, 2017 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save montj2/714b6d733306b5ccd7165499b579e647 to your computer and use it in GitHub Desktop.
Save montj2/714b6d733306b5ccd7165499b579e647 to your computer and use it in GitHub Desktop.
MacOS 10.9 - 10.13 Spotlight Reindexing Fix
#!/bin/bash
# Check for root/sudo
if [ "$(id -u)" != "0" ]; then
echo "This script should not be run using sudo or as the root user"
exit 1
fi
# Turn off indexing
echo "Turning off Spotlight indexing..."
sudo mdutil -a -i off
# Unload Spotlight
echo "Unloading Spotlight..."
launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
# Reload Spotlight
echo "Reloading Spotlight..."
launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
# Turn on indexing
echo "Turning on Spotlight indexing..."
sudo mdutil -a -i on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment