stmpclean(8)
| STMPCLEAN(8) | System Manager's Manual | STMPCLEAN(8) |
NAME
stmpclean — remove
old files from a world-writable directory
SYNOPSIS
stmpclean |
[-t<timespec>]
[-v] 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.
Anything that's not a directory, regular file, or symbolic link is also left
alone (because programs like screen(1)
create sockets and FIFOs under /tmp and expect them to be long-lived; we
accomodate this practice). Unlike floating around Perl scripts that do the
same task stmpclean never forks and consumes limited
amount of memory (these Perl scripts 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
-tflag 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). -v- Be verbose: list each file deleted.
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
In FreeBSD stmpclean invocation should be
placed into the file
/etc/periodic/daily/110.clean-tmps. In other
versions of BSD it should go into the /etc/daily
script. On LSB-compliant Linux distributions, the invocation of
stmpclean may be placed in a script under
/etc/cron.daily.
SEE ALSO
BUGS
When stmpclean scans a directory, access
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 delays removal of some empty directories.
| June 2003 | Linux 6.12.85-6.12-alt1 |
