Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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