System Administration Guide
Chapter 2, Administering filesystems

Finding temporary files

Finding temporary files

Use find with the -name option to locate temporary files for removal. 

A temporary file contains data created as an intermediate step during execution of a program. This file may be left behind if a program contained an error or was prematurely stopped by the user. The name of a temporary file depends on the program that created it. In most cases, the user has no use for temporary files, and you can safely remove them.

Use find to locate files with a specific name, such as temp. For example, to locate and display all files named temp under the /usr directory, enter:

find /usr -name temp -print

When searching for temporary files, it is a good idea to search for files that have not been accessed for a reasonable period of time. For example, to find all temp files in the /usr directory that have not been accessed for one week (-atime +7), enter:

find /usr -name temp -atime +7 -print

Once you locate the temp files, you can remove them automatically using the -exec option to find. See ``Executing commands based on find output''.