STMPCLEAN(8)

NAME
stmpclean - remove old files from a world-writable directory

SYNOPSIS
stmpclean [-t<timespec>] dir1 [dir2 ...]

DESCRIPTION
The stmpclean utility removes old files (and old empty directories) from the specified directory. It'll be typically used to clean directories such as ``/tmp'' where old files tend to accumulate.

The stmpclean utility never removes files or directories owned by root. It is a feature, not a bug. Great care is taken while descending into the directory, and the operation is secure. Unlike floating around Perl scripts that do the same task stmpclean never forks and consumes limited amount of memory (these Perl script easily turn into forking bombs when someone creates a lot a directories under ``/tmp''). If your system is attacked and the attacker creates an extremely deep file hierarchy, stmpclean won't add to the problem by crashing your system trying to remove it. But it won't help you in fighting the attack, either, because it descends only to a limited depth (currently, 30 levels). If stmpclean determines a race condition it'll log the situation (you can look for the word ``RACE'' in log files) and exit with a failure.

So, stmpclean will clean temporary directories for you fine when there are no attacks, and, when there is an attack, stmpclean won't make the situation worse (in particular, it cannot be tricked into removing files outside specified directories or consume unlimited amount of resources).

The following option is available:

-t<timespec>
    The time specification that follows the -t flag specifies how old a file or a directory has to be before it will be removed. It can be a string like `1w' (one week) or `4d5h' (four days plus five hours) or `2m3s' (two minutes plus three seconds). The default is `3d' (three days).

The stmpclean utility exits 0 on success, and >0 if an error occurs.

EXAMPLES
The stmpclean utility will typically be run nightly from cron(8) as

stmpclean /tmp /var/tmp

SEE ALSO
cron(8)

BUGS
When stmpclean removes a file from a directory, modification time of the directory changes and it looks new to stmpclean when it examines it later (if the directory became empty). Thus, removing a deep hierarchy can take some time. Notice, that this only applies to the time when an empty directory will be removed.