[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #51069] find changes access time on directories

From: Dale R. Worley
Subject: Re: [bug #51069] find changes access time on directories
Date: Mon, 22 May 2017 11:32:37 -0400

Adesh Kumar <address@hidden> writes:
> I thought "find" uses only stat syscalls, but yeah I can see how that
> cannot help with directory contents. My guess is that for simple tests
> like iname or name, find does not need to read the direcotry list. Is
> my understanding correct?

As I consider it intuitively (which, I believe, matches the Posix
specification), "find" is to search through the directory structure to
find files that match some criterion.  It is *inherent* in this action
that it has to read (that is, access) the directories it is searching
in, because (conceptually) a directory *is* a *list* of files, and to
search for a file in a directory, you have to read that list of files.

This reminds me of the time I used "tar" to perform backups, turning an
entire filesystem into an enormous tar file which was written to tape.
The problem is that "tar" reads the contents of files, which causes
their access times to be made current.  That effectively disabled the
script I ran which deleted *~ files that had not been accessed in 30
days.  I wrote the code for a "--atime-preserve" option for "tar" to fix
that.  (Which was enhanced by others to the current "tar" option.)

One way to make "find" not modify access times would be to use "touch"
to save and restore access times.  I think something like this might

before you do the real "find":
    find [directories] -type d -exec touch --reference={} {}/.atime-save \;

after you do the real "find":
    find [directories] -depth -type d \
        -exec touch --reference={}/.atime-save {} \; \
        -exec rm {}/.atime-save \;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]