I wrote a Perl script a few years ago that deletes files from a directory
that are older than n number of days. We generally set n to 30 days, but
you can set it to be anything you want.
#! /usr/bin/perl -w
use strict;
#
# Delete Backups - cjl 15-Jun-09
#
# This script is to run once a day from cron
#
# Delete files older than this number of days
my $too_old = 30;
# Change this path as appropriate
my $path = '/var/whatsit';
# Get the current epoch time
my $now = time;
# Get the list of files in the chosen directory
my @files = glob( "$path/*" );
my @when;
my $line;
# How many seconds in the time period
my $too_long = 86400 * $too_old;
while( @files ) {
$line = shift( @files );
chomp( $line );
@when = stat( $line );
# If the age of the file is > the expiration time, delete it
if(( $now - $when[10] ) > $too_long ) {
unlink( $line );
}
}
Curt
On Wed, Dec 5, 2012 at 2:01 PM, Howard White <[email protected]> wrote:
> So my predecessor set up our customer systems with background jobs writing
> results to local mail, /var/spool/mail/whomever. Just found one such
> system whereon the /var partition was nearly full. Is there a "logrotate"
> like utility to cull old stuff out of mail files, like on say a days-old
> factor or some such?
>
> Howard
>
> --
> You received this message because you are subscribed to the Google Groups
> "NLUG" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to nlug-talk+unsubscribe@**
> googlegroups.com <nlug-talk%[email protected]>
> For more options, visit this group at http://groups.google.com/**
> group/nlug-talk?hl=en <http://groups.google.com/group/nlug-talk?hl=en>
>
--
You received this message because you are subscribed to the Google Groups
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nlug-talk?hl=en