• 删除指定目录下的过期文件


    测试时,需要自动删除录制的文件,于是写了个脚本,自动删除过期的文件。

    如下:

     1 #!/bin/bash
    2 #待删除目录,根路径
    3 root_path="/figure/Record"
    4
    5 #保存时间:分钟
    6 save_time=1
    7
    8 for source_type in $(ls ${root_path})
    9 do
    10 if test -d ${root_path}/${source_type};then #录制对象目录
    11 cd ${root_path}/${source_type}
    12
    13 for channels in $(ls -b ${root_path}/${source_type}) #通道目录
    14 do
    15 if test -d ${channels};then
    16 cd ${channels}
    17
    18 for dates in $(ls ${root_path}/${source_type}/${channels}) #日期目录
    19 do
    20 if test -d ${dates};then
    21 cd ${root_path}/${source_type}/${channels}/${dates}
    22 find ${root_path}/${source_type}/${channels}/${dates} -type f -mmin ${save_time} -exec rm -fv '{}' \;
    23 fi
    24 done
    25 fi
    26 done
    27 else
    28 echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    29 fi
    30 done


     

  • 相关阅读:
    ThinkPHP5.1 行为与钩子
    PHP 商品秒杀抢购业务流程
    MySQL 读写分离
    Redis 管道
    Redis 事务
    Redis 锁机制
    ThinkPHP 实现队列
    MySQL 存储引擎
    分布式唯一ID分配问题
    Lightscape
  • 原文地址:https://www.cnblogs.com/chutianyao/p/2387967.html
Copyright © 2020-2023  润新知