Quick Linux Tip #61:
Question: Which files on my server haven't been touched in over a year?
Try: sudo find /home -type f -atime +365 -printf '%T@ %p\n' | sort -n | head -20
Info: -atime +365 filters files that have not been accessed in over a year. -printf '%T@ %p\n' adds a numeric timestamp and file path, allowing sort -n to order the results chronologically.
Examples:
- $
find /var/log -atime +90 -type f# Locate inactive log files - $
find /home -atime +365 -type f -exec ls -la {} \;# Inspect file metadata - $
find /tmp -atime +7 -type f -delete# Auto-purge temporary files older than 7 days
Note: Modern Linux filesystems commonly use relatime, which updates access time only under certain conditions. Combine -atime with -size +100M to identify large files that may be good candidates for archiving.
Leave a Reply