Find Files Not Accessed in Over a Year

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.




LinuxTeck.com
linuxteck@ubuntu:~$ sudo find /home -type f -atime +365 -printf '%T@ %p\n' | sort -n | head -5
1656789012.123 /home/linuxteck/old_projects/2023_report.pdf
1657123456.456 /home/linuxteck/archive/photos_backup.tar.gz
1657890234.789 /home/linuxteck/downloads/installer_v1.deb
1658234567.012 /home/linuxteck/docs/meeting_notes_jan.txt
1658901234.345 /home/linuxteck/tmp/scratch_data.csv

linuxteck@ubuntu:~$ sudo find /home -type f -atime +365 | wc -l
1247

linuxteck@ubuntu:~$

PREVIOUS ARTICLE Quick Linux Tip #60: How to Back Up a MySQL Database Without Downtime
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.