bighuen
asked on
delete files periodically
in one of my perl-cgi script, i create a file with random name when a user submit some information,
now there are more and more files,
i would like to delete some of them.
in my plan, i want to delete files of two days long automatically using a perl program.
can any one provide a script?
now there are more and more files,
i would like to delete some of them.
in my plan, i want to delete files of two days long automatically using a perl program.
can any one provide a script?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is it possible to use crontab or sth else that the program works automatically, no need i run the program many times?
#!/usr/local/bin/perl
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
require "find.pl";
# Traverse desired filesystems
&find('/directory/with/you
exit;
sub wanted {
(($dev,$ino,$mode,$nlink,$
-f _ &&
(int(-M _) > 2) &&
(unlink($_) || warn "$name: $!\n");
}