Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Deleting files older then 48 hours..

by sifukurt (Hermit)
on Nov 12, 2001 at 19:58 UTC ( [id://124850]=note: print w/replies, xml ) Need Help??


in reply to Deleting files older then 48 hours..

In the spirit of TMTOWTDI, here's a quick script that doesn't require any modules other than strict:
use strict; my $dir = "/home/sscripts/public_html/kage/"; my %ignore = ( 'blahblah.zip' => 1 ); my $seconds = 60 * 60 * 48; my $now = time(); print ("Content-type: text/html\n\n"); opendir ITEMS, $dir; my @files = grep !/^\./, readdir ITEMS; closedir ITEMS; chomp @files; chdir $dir; foreach my $file ( @files ) { if ( -d $file || defined $ignore{$file} ) { next } my $mod_time = ( stat($file) )[9]; my $when = localtime( $mod_time ); print ("$file $when<br>\n"); if ( $now - $seconds > $mod_time ) { unlink $file; } }
That's my 16**(1/4) cents. HTH
___________________
Kurt

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://124850]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found