How to Disable the Ubuntu ‘mlocate’ Daily Cron Job (High Disk Usage)

The I/O Bottleneck

In Ubuntu, the locate command is a blazingly fast way to find files on your system. It achieves this speed by searching a pre-compiled database rather than scanning the live hard drive. To keep this database accurate, Ubuntu uses a background service called mlocate (or plocate on newer versions), which runs a massive, system-wide cron job every single day (usually very early in the morning) to index every file on your drive.

If you are running an Ubuntu server with a massive amount of small files, or if you are running a desktop on an older, slow mechanical hard drive (HDD), this daily indexing process causes massive I/O (Input/Output) spikes. Your disk usage will shoot to 100%, and the entire system will become slow and unresponsive for several minutes while the database builds. If you rarely use the locate command, this background indexing is a severe waste of resources.

How to Disable the Mlocate Cron Job

You can prevent the indexer from running by removing its execution permissions.

  1. Open your Ubuntu Terminal (or connect via SSH).
  2. The indexing script is located in the daily cron directory. First, identify if you are using mlocate or plocate by listing the directory:
ls -l /etc/cron.daily/
  1. Look for a file named mlocate or plocate.
  2. To stop the system from executing this script, you must remove the executable (+x) bit from the file. Run the following command (adjust the filename if necessary):
sudo chmod -x /etc/cron.daily/mlocate
  1. Verify the change by listing the file again. It should no longer be colored green (indicating it is executable) in standard terminal themes:
ls -l /etc/cron.daily/mlocate

The cron daemon will now ignore the file during its daily maintenance routine. Your disk will no longer spike to 100% usage every morning. Note that the locate command will now return outdated results, so you should rely on the live find command instead.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.