in reply to del files that is 7 days or older
Or you could look at Date::Calc to do it your way.#!/usr/bin/perl opendir(DIR, "/home/archive/logs/old"); @FileList = readdir(DIR); closedir DIR; $current_epoch = timelocal ((localtime)[0,1,2,3,4,5]); foreach $file (@FileList) { $file .= "/home/archive/logs/old" . $file; $file_epoch = (stat($file))[9]; if (($current_epoch - $file_epoch) > "604800") { unlink("$file); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: del files that is 7 days or older
by merlyn (Sage) on Feb 15, 2001 at 00:55 UTC |