Finding and Removing old or inactive Files
In sequence to find inactive files, a user should first become the super user
Files which have not been accessed for a specified number of days can be found and listed in a file as given belows.
# find directory -type f [-atime + nnn][-mtime + nnn]-print > filename
In the syantax,
Directory - It refers to the directory which is to be checked .It below this also will be checked.
-atime +nnn - Finds files which have not been accessed inside the specified number of days.
-mtime +nnn - Finds files which have not been modified inside the specified number of days you specify.
Filename - It refers to the file holding the list of inactive files. The inactive files can now be deleted as given below
# rm 'cat filename'
Here
filename - It refers to the file created through this command that holds the list of inactive files.
Example - Removing and Finding Old or Inactive Files
The given example locates regular files in /var/adm and its directories which 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 within the rm command.
# find /var/adm -type f -atime +60 -print > /var/tmp/deadfiles &
# more /var/tmp/deadfiles
/var/adm/wtmp
/var/adm/wtmpx
/var/adm/sulog
# rm 'cat /var/tmp/deadfiles'