Portál AbcLinuxu, 12. května 2025 15:21
#!/bin/sh /usr/bin/updatedb -cVzhledem k tomu, že se mi na 700GB disku skoro nic nemění, tak mě zajímá, jestli má smysl spouštět denně takovýhle kanón na vrabce. Nezdá se mi, že by program měl nějaku volbu, aby otevíral jen změněné soubory: http://unixhelp.ed.ac.uk/CGI/man-cgi?updatedb+1 Vypadá to, že to vyrábí celou databázi úplně znovu. Řešíte spouštění updatedb jinak? děkuji za náměty.
Řešení dotazu:
Zdravim, co tak pouzit mlocate ? Vid nasledujuce :
pato@debian:~$ aptitude show mlocate
Package: mlocate
State: installed
Automatically installed: no
Version: 0.22.2-1
Priority: standard
Section: utils
Maintainer: Tollef Fog Heen <tfheen@debian.org>
Uncompressed Size: 582k
Depends: libc6 (>= 2.4), adduser
Conflicts: findutils (<= 4.2.31-1), slocate (<= 3.1-1.1)
Description: quickly find files on the filesystem based on their name
mlocate is a new implementation of locate, a tool to find files anywhere in the filesystem based on their name, using a fixed pattern or a regular expression. Unlike other tools like find(1), locate uses a previously created database to
perform the search, allowing queries to execute much faster. This database is updated periodically from cron.
Several implementations of locate exist: the original implementation from GNU's findutils, slocate, and mlocate. The advantages of mlocate are:
* it indexes all the filesystem, but results of a search will only include files that the user running locate has access to. It does this by updating the database as root, but making it unreadable for normal users, who can only access it
via the locate binary. slocate does this as well, but not the original locate.
* instead of re-reading all the contents of all directories each time the database is updated, mlocate keeps timestamp information in its database and can know if the contents of a directory changed without reading them again. This makes
updates much faster and less demanding on the hard drive. This feature is only found in mlocate.
Installing mlocate will change the /usr/bin/locate binary to point to mlocate via the alternatives mechanism. After installation, you may wish to run /etc/cron.daily/mlocate by hand to create the database, otherwise mlocate won't work
until that script is run from cron itself (since mlocate does not use the same database file as standard locate). Also, you may wish to remove the "locate" package in order not to have two different database files updated regularly on
your system.
Vsimni si hlavne to tucnym kurzivom zvyraznene. Presne to, co pozadujes od slocate, dokaze len mlocate. :)
root@dvouramenna:/etc/cron.daily# time /usr/bin/updatedb
real 7m36.371s
user 0m3.196s
sys 0m10.996s
Mlocate běží jen 7,5 minut.
Som rad, ze pomohlo. To bolo po prvykrat spustene? Lebo u mna to je takto:
root@debian:/tmp# time /usr/bin/updatedb
real 0m0.214s
user 0m0.084s
sys 0m0.072s
A to bude prave ta vyhoda mlocate, ze neindexuje kazdy adresar a jeho obsah pri kazdom update. A ja nemam vobec ani ponatia, ze tu nieco taketo bezi, co je skvele samozrejme. ;)
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.