JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris 11.1 Administration: Devices and File Systems     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

1.  Managing Removable Media (Tasks)

2.  Writing CDs and DVDs (Tasks)

3.  Managing Devices (Tasks)

4.  Dynamically Configuring Devices (Tasks)

5.  Managing USB Devices (Tasks)

6.  Using InfiniBand Devices (Overview/Tasks)

7.  Managing Disks (Overview)

8.  Managing Disk Use (Tasks)

Managing Disk Use (Task Map)

Displaying Information About Files and Disk Space

How to Display Information About Files and Disk Space

Checking the Size of Files

How to Display the Size of Files

How to Find Large Files

How to Find Files That Exceed a Specified Size Limit

Checking the Size of Directories

How to Display the Size of Directories, Subdirectories, and Files

How to Display the User Ownership of Local UFS File Systems

Finding and Removing Old or Inactive Files

How to List the Newest Files

How to Find and Remove Old or Inactive Files

How to Clear Out Temporary Directories

How to Find and Delete core Files

How to Delete Crash Dump Files

9.  Administering Disks (Tasks)

10.  Setting Up Disks (Tasks)

11.  Configuring Storage Devices With COMSTAR (Tasks)

12.  Configuring and Managing the Oracle Solaris Internet Storage Name Service (iSNS)

13.  The format Utility (Reference)

14.  Managing File Systems (Overview)

15.  Creating and Mounting File Systems (Tasks)

16.  Configuring Additional Swap Space (Tasks)

17.  Copying Files and File Systems (Tasks)

18.  Managing Tape Drives (Tasks)

Index

Finding and Removing Old or Inactive Files

Part of the job of cleaning up heavily loaded file systems involves locating and removing files that have not been used recently. You can locate unused files by using the ls or find commands. For more information, see the ls(1) and find(1) man pages.

Other ways to conserve disk space include emptying temporary directories such as the directories located in /var/tmp or /var/spool, and deleting core and crash dump files. For more information about crash dump files, refer to Chapter 1, Managing System Crash Information (Tasks), in Troubleshooting Typical Issues in Oracle Solaris 11.1.

How to List the Newest Files

Example 8-10 Listing the Newest Files

The following example shows how to use the ls -tl command to locate the most recently created or changed files within the /var/adm directory. The sulog file was created or edited most recently.

$ ls -tl /var/adm
total 134
-rw-------   1 root     root         315 Sep 24 14:00 sulog
-r--r--r--   1 root     other     350700 Sep 22 11:04 lastlog
-rw-r--r--   1 root     bin         4464 Sep 22 11:04 utmpx
-rw-r--r--   1 adm      adm        20088 Sep 22 11:04 wtmpx
-rw-r--r--   1 root     other          0 Sep 19 03:10 messages
-rw-r--r--   1 root     other          0 Sep 12 03:10 messages.0
-rw-r--r--   1 root     root       11510 Sep 10 16:13 messages.1
-rw-r--r--   1 root     root           0 Sep 10 16:12 vold.log
drwxr-xr-x   2 root     sys          512 Sep 10 15:33 sm.bin
drwxrwxr-x   5 adm      adm          512 Sep 10 15:19 acct
drwxrwxr-x   2 adm      sys          512 Sep 10 15:19 sa
-rw-------   1 uucp     bin            0 Sep 10 15:17 aculog
-rw-rw-rw-   1 root     bin            0 Sep 10 15:17 spellhist
drwxr-xr-x   2 adm      adm          512 Sep 10 15:17 log
drwxr-xr-x   2 adm      adm          512 Sep 10 15:17 passwd

How to Find and Remove Old or Inactive Files

  1. Become an administrator.

    For more information, see How to Use Your Assigned Administrative Rights in Oracle Solaris 11.1 Administration: Security Services.

  2. 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

    Identifies the directory you want to search. Directories below this directory are also searched.

    -atime +nnn

    Finds files that have not been accessed within the number of days (nnn) that you specify.

    -mtime +nnn

    Finds files that have not been modified within the number of days (nnn) that you specify.

    filename

    Identifies the file that contains the list of inactive files.

  3. Remove the inactive files found listed in the previous step.
    # rm `cat filename`

    where filename identifies the file that was created in the previous step. This file contains the list of inactive files.

Example 8-11 Finding and Removing Old or Inactive Files

The following example shows files in the /var/adm directory and the subdirectories that have not been accessed in the last 60 days. The /var/tmp/deadfiles file contains the list of inactive files. The rm command removes these inactive files.

# find /var/adm -type f -atime +60 -print > /var/tmp/deadfiles &
# more /var/tmp/deadfiles
/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`
#

How to Clear Out Temporary Directories

  1. Become an administrator.

    For more information, see How to Use Your Assigned Administrative Rights in Oracle Solaris 11.1 Administration: Security Services.

  2. Change to the directory that you want to clean out.
    # cd directory

    Caution

    Caution - Ensure that you are in the correct directory before completing Step 3. Step 3 deletes all files in the current directory.


  3. Delete the files and subdirectories in the current directory.
    # rm -r *
  4. Change to other directories that contain unnecessary, temporary or obsolete subdirectories and files.
  5. Delete these subdirectories and files by repeating Step 3.

Example 8-12 Clearing Out Temporary Directories

The following example shows how to clear out the mywork directory, and how to verify that all files and subdirectories were removed.

# cd mywork
# ls
filea.000
fileb.000
filec.001
# rm -r *
# ls
#

How to Find and Delete core Files

  1. Become an administrator.

    Change to the directory where you want to search for core files.

  2. Find and remove any core files in this directory and its subdirectories.
    # find . -name core -exec rm {} \;

Example 8-13 Finding and Deleting core Files

The following example shows how to find and remove core files from the jones user account by using the find command.

# cd /home/jones
# find . -name core -exec rm {} \;

How to Delete Crash Dump Files

Crash dump files can be very large. If you have enabled your system to store these files, do not retain them for longer than necessary.

  1. Become an administrator.

    For more information, see How to Use Your Assigned Administrative Rights in Oracle Solaris 11.1 Administration: Security Services.

  2. Change to the directory where crash dump files are stored.
    # cd /var/crash/system

    where system identifies a system that created the crash dump files.


    Caution

    Caution - Ensure you are in the correct directory before completing Step 3. Step 3 deletes all files in the current directory.


  3. Remove the crash dump files.
    # rm *
  4. Verify that the crash dump files were removed.
    # ls

Example 8-14 Deleting Crash Dump Files

The following example shows how to remove crash dump files from the system venus, and how to verify that the crash dump files were removed.

# cd /var/crash/venus
# rm *
# ls