Use the ls –t command to generate a list of files in a directory and sort them according to their respective time stamps. By default, the files will be listed from the newest files to the oldest. The following example lists the files in /var/adm starting from the most recent file.
$ ls -t /var/adm total 134 -rw------- 1 root root 315 Sep 24 14:00 sulog -rw-r--r-- 1 root root 11510 Sep 10 16:13 messages.1 drwxrwxr-x 5 adm adm 512 Sep 10 15:19 acct drwxrwxr-x 2 adm sys 512 Sep 10 15:19 sa drwxr-xr-x 2 adm adm 512 Sep 10 15:17 log
You can use this information to remove old files that you determine you no longer need.
For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.4.
# find directory -type f[-atime +nnn] [-mtime +nnn] -print > output-file &
The directory you want to search, which includes its subdirectories.
The number of days that files that have not been accessed.
The number of days that files have not been modified.
The file to which the output of the command will be written.
If some files in the list are still needed, delete them from the output file.
# rm `cat output-file`
This example creates a list of the files in the /var/share/adm directory and its subdirectories that have not been accessed in the last 60 days in a file named /var/tmp/deadfiles. The rm command removes the inactive files listed in the /var/tmp/deadfiles file.
# find /var/adm -type f -atime +60 -print > /var/tmp/deadfiles & # more /var/tmp/deadfiles /var/adm/aculog /var/adm/spellhist /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` #