A common mistake is that ctime is the file creation time. This is not
correct, it is the inode/file change time. mtime is the file
modification time. A often heard question is "What is the ctime, mtime
and atime?".This is confusing so let me explain the difference between
ctime, mtime and atime.
ctime
ctime is the inode or file change time. The ctime gets updated when the file attributes are changed, like changing the owner, changing the permission or moving the file to an other filesystem but will also be updated when you modify a file.mtime
mtime is the file modify time. The mtime gets updated when you modify a file. Whenever you update content of a file or save a file the mtime gets updated.Most of the times ctime and mtime will be the same, unless only the file attributes are updated. In that case only the ctime gets updated.
atime
atime is the file access time. The atime gets updated when you open a file but also when a file is used for other operations like grep, sort, cat, head, tail and so on.In the descriptions, wherevern
is used as a primary argument, it shall be interpreted as a decimal integer optionally preceded by a plus ( '+' ) or minus-sign ( '-' ) sign, as follows:
+n
More thann
.
n
Exactlyn
.
-n
Less thann
.
At the given time (2014-09-01 00:53:44 -4:00, where I'm deducing that AST is Atlantic Standard Time, and therefore the time zone offset from UTC is -4:00 in ISO 8601 but +4:00 in ISO 9945 (POSIX), but it doesn't matter all that much):
1409547224 = 2014-09-01 00:53:44 -04:00
1409457540 = 2014-08-30 23:59:00 -04:00
so:1409547224 - 1409457540 = 89684
89684 / 86400 = 1
Even if the 'seconds since the epoch' values are wrong, the relative
values are correct (for some time zone somewhere in the world, they are
correct).The
n
value calculated for the 2014-08-30 log file therefore is exactly 1
(the calculation is done with integer arithmetic), and the +1
rejects it because it is strictly a > 1
comparison (and not >= 1
)."-mtime -2" means files that are less than 2 days old, such as a file that is 0 or 1 days old.
"-mtime +2" means files that are more than 2 days old... {3, 4, 5, ...}
The argument to
-mtime
is interpreted as the number of whole days in the age of the file. -mtime +n
means strictly greater than, -mtime -n
means strictly less than.Note that with Bash, you can do the more intuitive:
$ find . -mmin +$((60*24))
$ find . -mmin -$((60*24))
to find files older and newer than 24 hours, respectively.
No comments:
Post a Comment