Chinaunix首页 | 论坛 | 博客
  • 博客访问: 466720
  • 博文数量: 279
  • 博客积分: 4467
  • 博客等级: 上校
  • 技术积分: 2830
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-03 14:43
文章分类

全部博文(279)

文章存档

2013年(1)

2012年(39)

2011年(35)

2009年(29)

2008年(131)

2007年(44)

分类:

2008-06-13 12:51:34

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);
         }
        }
      }

阅读(242) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~