Become superuser.
Find files that have not been accessed for a specified number of days and list them in a file.
# find directory -type f[-atime + nnn] [-mtime + nnn] -print > filename |
directory |
Directory you want to check. Directories below this also will be checked. |
-atime +nnn |
Finds files that have not been accessed within the number of days you specify. |
-mtime +nnn |
Finds files that have not been modified within the number of days you specify. |
filename |
Remove the inactive files that you listed in the previous step.
# rm `cat filename` |
filename |
File created in previous step which contains the list of inactive files. |
The following example locates regular files in /var/adm and its directories that have not been accessed in the last 60 days and saves the list of inactive files in /var/tmp/deadfiles. These files are then removed with the rm command.
# find /var/adm -type f -atime +60 -print > /var/tmp/deadfiles & # more /var/tmp/deadfiles /var/adm/log/asppp.log /var/adm/aculog /var/adm/spellhist /var/adm/wtmpx /var/adm/sa/sa13 /var/adm/sa/sa27 /var/adm/sa/sa11 /var/adm/sa/sa23 /var/adm/sulog /var/adm/vold.log /var/adm/messages.1 /var/adm/messages.2 /var/adm/messages.3 # rm `cat /var/tmp/deadfiles` # |