On Wed, Feb 19, 2003 at 04:19:11PM -0500, Paul wrote:
The reason I had mentioned stat is for the possibility of scripting with
it to get a list of modified files for backup.
You probably really want to be using Perl's stat function for this
rather than trying to parse the string output of a shell command.
stat(1)'s just a wrapper around the stat(2) syscall, which you'd do
far better to just use directly.
On Wed, Feb 19, 2003 at 04:35:14PM -0500, Walt Mankowski wrote:
On Wed, Feb 19, 2003 at 04:19:11PM -0500, Paul wrote:
I'm running stat 3.0 under RedHat 8.0 and it has the same options. What
is the difference between "modification" and "change" in practical terms?
From the man page for the stat(2) system call:
The field st_mtime is changed by file modifications, e.g. by
mknod(2), truncate(2), utime(2) and write(2) (of more than zero
bytes). Moreover, st_mtime of a directory is changed by the
creation or deletion of files in that directory. The st_mtime field
is not changed for changes in owner, group, hard link count, or
mode.
The field st_ctime is changed by writing or by setting inode
information (i.e., owner, group, link count, mode, etc.).
That doesn't make things as clear as it could. For your purposes,
Paul, ctime is as close to creation time as you're going to get.
ctime DOES change with changes in owner, group, hard link or mode.
Those are changes to the inode where the file is stored. Any change
to the file's *contents* changes mtime.
You can't get both in the same place and you can't get any real
"creation time" at all, though it's often sufficient to treat ctime
as it. (If you do this, you should be aware of the situations in
which that assumption will break down.)