in reply to Quickest way to get the oldest file
Others have suggested you use a database and I tend to agree with them. It's unclear whether you meant 50,000 files or 50,000 directories each with some number of files but either way, searching through that many entries in a filesystem is slow (and hopefully it's not 50,000 files all in one directory!) Another mechanism that you might be able to use is encoding the time information in the file/directory names themselves. Something like:
2004/01/19/00/filename.01 2004/01/19/00/filename.02 2004/01/19/00/filename.03 ... 2004/01/19/01/filename.01 ... 2004/01/19/02/filename.01 ...
In this hypothetical example the files are arranged by year/month/day/hour/filename.minute. You can see that it would be relatively easy to find the oldest file if you could arrange for such a structure. I don't exactly know if this technique would be useful to your problem, but there it is.
Or you could just use a database like postgres, mysql, berkeley DB, etc. (I believe all of these are available on both linux and windows) with an index created on the time of each entry. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Quickest way to get the oldest file
by Anonymous Monk on Jan 20, 2004 at 20:24 UTC |