Re: Safe /tmp cleanup

Randal Schwartz (merlyn@STONEHENGE.COM)
Thu, 13 Nov 1997 00:38:33 -0700

>>>>> "Steven" == Steven Leikeim <steven@ENEL.UCALGARY.CA> writes:

Steven> In Red Hat Linux 4.2, there is a package called tmpwatch. Here is the
Steven> first part of the man page:

Steven> NAME
Steven> tmpwatch - removes files which haven't been accessed for a period
Steven> of time

Steven> SYNOPSIS
Steven> tmpwatch [-fav] [--verbose] [--force] [--all] [--test] <hours>
Steven> <dirs>

Delete all files that haven't been accessed in 1.5 days in /dir and /ect:

find2perl /dir /ect -eval '-A > 1.5 and unlink' | perl

Steven> The source for this program is 294 lines of C (including comments).

And completely unnecessary, given the above perl command-line. :-)

The output of this find2perl run is 17 lines of Perl, by the way.

Steven> Enough care seems to have been taken to avoid race hazards
Steven> and my limited examination of code satisfied me that there are
Steven> no security problems with it. Specfically, the program does
Steven> everything itself, it does not rely on an external program for
Steven> any function which should eliminate problems associated with
Steven> special characters and/or buffer overflows due to deep paths.

Ditto on the find2perl solution.

"find2perl" comes with all modern Perl releases.

Perl is your friend. Use Perl.

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me