how to build database for locate?

on OS 15.1 I have the comman locate, but the datebase seems to be no longer build as a system service.

can anyone please tell me how to set up that the database for locate is build automatically like in the “old times”?


sudo updatedb

Its there:

systemctl status mlocate.timer 
● mlocate.timer - Daily locate database update
   Loaded: loaded (/usr/lib/systemd/system/mlocate.timer; enabled; vendor preset: disabled)
   Active: active (waiting) since Thu 2019-10-03 15:18:31 CEST; 2h 49min ago
  Trigger: Fri 2019-10-04 00:00:00 CEST; 5h 51min left
     Docs: man:updatedb

Oct 03 15:18:31 linux64 systemd[1]: Started Daily locate database update.

Or by Hand:

systemctl start mlocate.service

machine running openSUSE Tumbleweed I’m getting an error as follows:

Thinkcentre-M57p:~> systemctl start updatedb.timer
Failed to start updatedb.timer: Unit updatedb.timer not found.
paul@paul-Thinkcentre-M57p:~> systemctl status mlocate.timer
● mlocate.timer - Daily locate database update
     Loaded: loaded (/usr/lib/systemd/system/mlocate.timer; enabled; preset: enabled)
     Active: active (waiting) since Fri 2024-01-12 00:15:01 CST; 21min ago
    Trigger: Sat 2024-01-13 00:00:00 CST; 23h left
   Triggers: ● mlocate.service
       Docs: man:updatedb

**Warning: some journal files were not opened due to insufficient permissions.**

Thinkcentre-M57p:~>

  1. Wondering where to start looking and if this is common?
  2. Is this the proper workaround? → https://www.suse.com/support/kb/doc/?id=000021204
  3. Workaround? chmod o+r /var/lib/mlocate/mlocate.db

-Thanks

I attempted the permission modification shown above with no joy afterwards. I am leaning towards this not being the workaround being experienced with mlocate on this machine currently. I reverted to default permissions. Your ideas are most welcome.

Thanks

Added group membership:

karl@erlangen:~> LANG=C id
uid=1000(karl) gid=100(users) groups=100(users),999(systemd-journal)
karl@erlangen:~> 

journal shows everything when invoked by user karl:

karl@erlangen:~> systemctl status mlocate.timer
● mlocate.timer - Daily locate database update
     Loaded: loaded (/usr/lib/systemd/system/mlocate.timer; enabled; preset: enabled)
     Active: active (waiting) since Wed 2024-01-10 19:19:09 CET; 1 day 12h ago
    Trigger: Sat 2024-01-13 00:00:00 CET; 15h left
   Triggers: ● mlocate.service
       Docs: man:updatedb

Jan 10 19:19:09 erlangen systemd[1]: Started Daily locate database update.
karl@erlangen:~> 

@panorain any system based services need to be started as root user, not your normal user, hence the error…

Once you get comfortable with system maintenance, then could look at adding your user to system groups, but to be on the safe side, I would suggest you don’t…

Thank you for your insight, please take a brief moment to review the output below:

Thinkcentre-M57p:~> systemctl status mlocate.timer
● mlocate.timer - Daily locate database update
     Loaded: loaded (/usr/lib/systemd/system/mlocate.timer; enabled; preset: enabled)
     Active: active (waiting) since Fri 2024-01-12 11:00:23 CST; 5min ago
    Trigger: Sat 2024-01-13 00:00:00 CST; 12h left
   Triggers: ● mlocate.service
       Docs: man:updatedb

Warning: some journal files were not opened due to insufficient permissions.
  1. When I see the above line I interpreted it as error not as root files correct?
    ─systemd-journald.service
    │ │ └─788 /usr/lib/systemd/systemd-journald

  2. Looks like the service systemd-journald has been in fact started.

Thinkcentre-M57p:~> sudo updatedb
[sudo] password for root: 
Thinkcentre-M57p:~>
  1. Then simply passing locate brother displays a myriad of files displaying brother wthin the file name. Below is a small sample of some of the files. located by passing locate brother
Thinkcentre-M57p:~> locate brother
/etc/opt/brother
/etc/opt/brother/scanner
/etc/opt/brother/scanner/brscan-skey
/etc/opt/brother/scanner/brscan4
/etc/opt/brother/scanner/brscan-skey/brscan-skey.config
/etc/opt/brother/scanner/brscan-skey/brscan-snmp.cfg
/etc/opt/brother/scanner/brscan-skey/brscan_mail.config
/etc/opt/brother/scanner/brscan-skey/brscan_mailmessage.txt
/etc/opt/brother/scanner/brscan-skey/scantoemail.config
/etc/opt/brother/scanner/brscan-skey/scantofile.config
/etc/opt/brother/scanner/brscan-skey/scantoimage.config
/etc/opt/brother/scanner/brscan-skey/scantoocr.config
/etc/opt/brother/scanner/brscan4/Brsane4.ini
/etc/opt/brother/scanner/brscan4/brsanenetdevice4.cfg
/etc/opt/brother/scanner/brscan4/models4

I was thinking some sort of permission error having to do with user related files not considering important system files with root:root group ownership. Hence the warning Warning: some journal files were not opened due to insufficient permissions. hmm

  1. I believe I do not need to pass updatedb prior to using locate mlocate.timer target is set to
Daily locate database update
  1. Is this somewhat correct assumption on my part?

-Thanks

Correct, the systemd timer takes care of updating the database every day. But if you want to update it manually for some reason you can always do so (either by starting the service once or by running updatedb - either one as root).

The index is generated as root, but the database is readable by your normal user. Hence you will also find files you don’t have direct permission to read in the locate output, this is expected.

1 Like