3

On a standard desktop installation of Ubuntu 24.04, when I try to use the locate command, searches for files that I clearly have in my home directory do not show up -- it appears as if the locate database has never been updated.

However, I can run sudo updatedb, which manually updates the locate database, and I can then search for files as expected. This continues to work for a day, after which searches for files in my home directory no longer work again. So my assumption is that after the locate script in cron.daily runs, the database is altered or erased.

One solution would be to just remove the locate script from cron.daily, which I think would "solve" the problem. But is there a more proper way to handle this?

4
  • In Ubuntu 22.04 with the default plocate (so likely in 24.04 as well) the /etc/cron.daily/plocate script simply exits if it detects systemd - the updating is nowadays handled via plocate-updatedb.service using a systemd timer. Commented May 11, 2024 at 10:24
  • @steeldriver It's still the issue that the user's locate database never updates though, so it seems their systemd service isn't triggering (that's half a statement and half a question). Commented May 11, 2024 at 10:57
  • 1
    @Kusalananda indeed - I didn't mean to imply otherwise, just that they probably needed to look elsewhere. AFAIK the plocate-updatedb.service just runs the same updatedb.plocate with the same /etc/updatedb.conf as executing updatedb manually - so the issue needs some deeper digging. Commented May 11, 2024 at 11:12
  • ... perhaps a good place to start would be systemctl list-timers plocate-updatedb Commented May 11, 2024 at 11:38

2 Answers 2

0

This can be fixed by changing the line

LOCALUSER=nobody

in crond.daily into

LOCALUSER=root

I think this is safe since updatedb must be run as root anyway.

1
  • I think that can be a potential for security issues. If a file is hidden, there's probably a good reason (i.e. a certificate, secret log files, etc.) Commented Mar 15 at 1:06
0

I had that problem too. It looks like the auto-update timer is not being started automatically. I had to run the following:

$ sudo systemctl start plocate-updatedb.timer

If you want to know whether the state is active or not before and after running the command above, you can use the status command:

$ systemctl status plocate-updatedb.timer
○ plocate-updatedb.timer - Update the plocate database daily
     Loaded: loaded (/usr/lib/systemd/system/plocate-updatedb.timer; enabled; preset: enabled)
     Active: inactive (dead)
    Trigger: n/a
   Triggers: ● plocate-updatedb.service

As we can see, the default (it looks like) is to leave that timer as inactive. Once you run the start command once, it should be active forever.

If you want to update the database immediately, you can run the command manually, but if like me your hard drives are Tb of data...

$ sudo updatedb

The timer above also needs to be enabled. It was for me. If yours is marked as being disabled, then also run that command:

$ sudo systemctl enable plocate-updatedb.timer

Found the hint here: https://bbs.archlinux.org/viewtopic.php?id=299301

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.