NAME

cleandir - remove unused files from directory


SYNOPSIS

cleandir [-d days] [-n] [-m] [-v] [-s] [-i|-x regex] directory...


DESCRIPTION

cleandir recursively searches each directory given on the commandline for files and subdirectories which have not been accessed for n days and deletes them. It is intended to be used on /tmp and other world-writable directories and implements a number of checks to prevent symlink or directory switching attacks. It also does not cross mount points.


OPTIONS

-d days

Delete files which have not been accessed for the given number of days. The default is 14.

-m

Consider only the last modification time of the file, not the last access time.

-c

Consider only the inode change time of the file.

-n

No-op. Don't delete any files.

-s

Skip sockets and named pipes. Some programs (notably X11 and some databases) create sockets and named pipes in /tmp and foolishly expect them to survive. This option exists to humour them.

-v

Verbose. Can be repeated to increase verbosity.

-i|-x regex

Include and exclude patterns. The filenames (not the complete path) of all files and directories to be removed are compared against these patterns in order. The first hit determines the action. These patterns can also be used to override the -s option and to cross mount points.


AUTHOR

Peter J. Holzer <hjp@hjp.at>. Thanks to Chris Mason for some enhancements.