Note that there are some explanatory texts on larger screens.

plurals
  1. POquickest way to count the number of files in a directory containing hundreds of thousands of files
    primarykey
    data
    text
    <p>In a solaris system that processes large numbers of files and stores their information in a database (yes i know that using the database is the quickest way to get information about the number of files we have). I need fast way to monitor the files as they progress through the system on their way to being stored in a database.</p> <p>Currently I use a perl script that reads in the directory to an array and then grabs the size of the array and sends it to a monitoring script. Unfortunately as our system grows this monitor is getting more and more slow.</p> <p>I am looking for a method that will operate much more quickly instead of pausing and updating every 15-20 seconds after performing the count operation on all the directories involved.</p> <p>I am relatively certain that my bottleneck is the read directory into array operation.</p> <p>I don't need any information about the files, I don't need sizes or file names, just the number of files in the directory.</p> <p>In my code I do not count hidden files or the text files I use to hold configuration information. It would be great if this functionality was preserved but is certainly not mandatory.</p> <p>I have found some references to counting inodes with C code or something along those lines but I am not very experienced in that area.</p> <p>I would like to make this monitor as real-time as possible.</p> <p>The perl code I use looks like this:</p> <pre><code>opendir (DIR, $currentDir) or die "Cannot open directory: $!"; @files = grep ! m/^\./ &amp;&amp; ! /config_file/, readdir DIR; # skip hidden files and config files closedir(DIR); $count = @files; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload