Skip to main content

Stale Results

The most common issue with locate is that it is only as accurate as the last time updatedb was run.

Issue: Deleted Files Still Showing Up

If you delete a file, locate will still show it until the next database update.

Solution: Use -e The -e (--existing) flag checks if the file still exists on disk before printing it.

locate -e myfile.txt

Issue: New Files Not Found

If you just created a file, locate won't know about it yet.

Solution: Run updatedb Manually refresh the database to include recent changes.

sudo updatedb
locate mynewfile.txt

Issue: Database Age

If your system changes frequently, the default daily cron job might not be enough.

Check Age:

stat /var/lib/mlocate/mlocate.db

Increase Frequency: Consider running updatedb via crontab every hour if needed.