Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to get a reliable progress bar (or just a reliable information how long it will take) when doing updatedb?

share|improve this question
up vote 3 down vote accepted

No, there's no such option, as well it shouldn't have any.

If you need to measure that, you must first know how many files are present on your system, that means loop through everything twice, it can be slow

One evicent example is that if you extract kernel source code with file-roller, it's slower than doing the same thing with tar directly, because file-roller need to file out all files first(otherwise the progress bar might be incorrectly displayed), and you wait for a while before extraction process actually began.

share|improve this answer
You are totally right. However, it would be possible to predict the time for the next run using a “smart guess”. For instance one could compute an exponentially weighted moving average from the past values, which basically assumes that the next run will take as long as the average of the last runs. This is of course not exact, but very cheap to compute since it doesn't loop over the file system. Given that neither the amount of files nor the load changes dramatically it will yield to very practical estimated values. – Marco Jan 12 '13 at 14:00

This is not an efficient solution, but is not as bad as looping through everything twice.

Number of files processed by updatedb is equal to:

updatedb -v | wc -l

or roughly equal to:

find / -mount | wc -l

We cannot use these commands to get the number, because it would be looping twice.

But we can use the number of used inodes, which is approximately the same:

df -i | grep '/$' | awk '{print $3}'

Having this value, we can calculate how far we got while updatedb -v command is running:

count=$(df -i | grep '/$' | awk '{print $3}')

sudo updatedb -v | while read
    printf "%3d\r" $((100 * (++i) / count))

This is very inefficient, because printf is called for every line in the output of updatedb -v. Better if we printf for only some of the lines.

count=$(df -i | grep '/$' | awk '{print $3}')

sudo updatedb -v | while read
    if (( ++i % (count/20) == 0 )); then
        printf "%3d\r" $((100 * i / count))
share|improve this answer
Interesting idea. But my df -i reports 0 in all columns for /. Maybe extracting the current database's file count from locate -S (or --statistics or other similar switch your locate implementation has) could also be used as an approximative file count. – manatwork Jul 18 '12 at 14:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.