Question: How do I check when a file was last read without changing that timestamp?
Try: stat -c '%n Access: %x Modify: %y Change: %z' /var/log/syslog
Info: stat with -c custom formatting lets you inspect a file's timestamps without reading its contents like cat would. The format specifiers %x show access time (atime), %y shows modification time (mtime), and %z shows change time (ctime).
Examples:
- $
stat -c '%Y' file# Show modification time as a Unix timestamp - $
find /home -atime +90# Find files not accessed in 90+ days - $
mount -o noatime /dev/sda1 /mnt# Disable access-time updates
Note: atime records file access, but modern Linux systems commonly use relatime, which reduces how often access times are updated. As a result, atime should not always be interpreted as the exact time of the most recent read. Use stat when you need to inspect timestamps without opening the file for reading.
Leave a Reply