10. filecleanup 30
Description: it will clean all old file (file create time) more than 30 days.
usage: filecleanup30.pl
#!/usr/bin/perl
require '/opt/ws1/run_control.pl'; use Date::Manip; foreach $target(qw($ftpuploaddirectory $ftpdownloaddirectory)){ opendir(DIR,"$target")or die "cannot open $target:$!\n"; foreach $dir(readdir DIR){ if($dir ne '.' && $dir ne '..'){ $sub="$target".'/'."$dir"; if(-d $sub){ opendir(SUB,"$sub")or die "can't open $sub:$\n"; foreach (readdir SUB){ if($_ ne '.' && $_ ne '..'){ $file=$sub.'/'.$_; if (! -d $file){ print "$file\n"; &file_delete($file); } } else{ next; } } } else{ if (! -d $sub){ print "$sub\n"; &file_delete($sub); } } }
|
阅读(290) | 评论(0) | 转发(0) |