find and Access Times

  • find can match by inode timestamps
    • -atime when file was last read
    • -mtime when file data last changed
    • -ctime when file data or metadata last changed
  • Value given is in days
    • find /tmp -ctime +10
      • files changed more than 10 days ago
  • Can use a vlue of minutes
    • -amin
    • -mmin
    • -cmin
    • find /etc -amin -60

Examples of find timestamp-matching criteria are given in the previous Post Find and Numeric Criteria. While the values passed to -atime, -ctime and -mtime are measured in days, there are also corresponding criteria that perform searches in minutes: -amin, -cmin and -mmin. You can evern match access times relative to the timestamps of other files using -anewer, -cnewer and -newer, which tests mtime. For example:

[user@user-pc ~]$ find -newer recent_file.txt

Would list all files with mtimes more recent than that of recent_file.txt. Note that there is no -older argument. To match files older than recent_file.txt you would simply negate the -newer criteria:

[user@user-pc ~]$ find -not -newer recent_file.txt

Remember that the metadata, including all three timestamps, for a file can be manually examined using the stat command.

Leave a Comment

%d bloggers like this: