源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

服务器自动删除文件的脚本

  • 时间:2021-02-09 18:26 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:服务器自动删除文件的脚本
支持匹配路径 匹配文件名  多久没有访问的自动清理
[u]复制代码[/u] 代码如下:
#用于各系统清理文件脚本,filepath  reg_filename fileatime #author Foyon0806@gmail.com #date   2013-8-22 14:51:52 #!/bin/sh if [ $# -eq 0 ];then     echo "Usage: sh auto_clear_file.sh clear_filepath clear_regfilename filecreatetime"     echo "eg: sh auto_clear_file.sh /tmp/log/  user_log -7day"     exit fi filepath=$1 regfilename=$2 if [ "-$3" = "-" ];then     filectime=`date -d -7day '+ %s'` else     filectime=`date -d $3 '+ %s'` fi log=`ls $filepath | grep $regfilename` echo $log for file in ${log} do     echo $file     fileatime=`stat -c %X ${filepath}${file}`     if [ ${fileatime} -lt ${filectime} ]; then         opt=`rm -f ${filepath}${file}`         echo $opt     fi  done
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部