I think you can use Unix find command for that. You can also use Perl for that using Find::File or File::Find::Rule. Check also -X and stat for more information on how get the creation date of some file.
Igor 'izut' Sutton
your code, your rules.
| [reply] [d/l] |
Look at "perldoc -f -X", especially "-M" -- that reports the age of the file in days (a floating point number) relative to the time that the script started. (It's actually based on the date and time of "last modification" of the file, not "creation", but that shouldn't make any difference for you.)
Also, File::Find (or anything related to it) is overkill if you just have one directory (no subdirectories) where the temp files are kept:
# get a list of data files that are at least one day old in /my/tmpdir
+:
opendir( TMP, "/my/tmpdir" );
my @dayold = grep { /[^.]/ and -f and -M _ > 1 } readdir TMP;
closedir TMP;
# don't like old files? kill 'em off:
unlink map { "/my/tmpdir/$_" } @dayold;
If you want to focus on files that are, say, just 2 hours old or older, use "2/24" instead of "1" to test against the value of "-M". | [reply] [d/l] |