FreeKB - Linux Commands find command - date accessed (-atime)
Linux Commands - find command - date accessed (-atime)

The -atime option can be used to return files and directories that were accessed x or more days ago. For example, to return files and directories that were accessed 14 or more days ago below the tmp directory.

find /tmp -atime +14

 

To return files and directories that were not accessed 14 or more days ago below the tmp directory.

find /tmp ! -atime +14

 

NOTE - Listing a files attributes will not update the last accessed datetime of the file. You would need to do something like cat or touch to update the last accessed datetime of the file.

  • The -mtime option can be used to return files and directories that were modified x or more days ago.
  • The -ctime option can be used to return files and directories that were changed x or more days ago.

 

To include the date and time the file was last accessed in the output.

  • %x = time last accessed
  • %n = file name
find /tmp -exec stat --format  "%x %n" "{}" \;

 

This will return something like this.

2020-07-06 05:50:18.594805437 -0500 /tmp/foo.txt
2020-07-06 02:10:38.898884577 -0500 /tmp/bar.txt

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter a94f3 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |