Random Musings

Sporadic thoughts on tech, economics, business, finance and trading

Where exactly is the cronjob for updatedb as I have never seen it in any of the crontabs?

,

You won’t typically find updatedb explicitly listed in user crontabs like /etc/crontab or under crontab -e. Instead, the updatedb command is generally managed through systemd timers or system-wide cron jobs specific to certain package-managed cron directories.

Here’s where it might be scheduled:

  1. Systemd Timer:
    • In many modern Linux distributions (such as Fedora, Ubuntu, and Arch), updatedb is run by a systemd timer. You can check if this is active with: systemctl list-timers | grep mlocate
    • For mlocate, it often uses a timer called mlocate-updatedb.timer, which is configured to run at intervals defined by the distribution. If present, it can be found in /usr/lib/systemd/system/ or /etc/systemd/system/.
  2. Cron Directory:
    • In distributions where systemd is not used, updatedb might be scheduled in a cron directory, commonly found in /etc/cron.daily/ or /etc/cron.weekly/. These scripts are run automatically at specific intervals by the cron service.
    • Look for an mlocate or updatedb script within these directories. For example: ls /etc/cron.daily | grep mlocate
  3. Legacy Location (/etc/crontab):
    • In some older setups, updatedb is directly scheduled in /etc/crontab. However, this is less common now due to the adoption of systemd timers and separate cron directories.

You can also manually trigger an updatedb run if needed by simply executing:

sudo updatedb

This variety in scheduling method can depend on the distribution and the version of the mlocate or slocate package installed.