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

2023-12-05 0 170

支持匹配路径 匹配文件名 多久没有访问的自动清理


复制代码 代码如下:#用于各系统清理文件脚本,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\” exitfi


filepath=$1regfilename=$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) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 Perl 服务器自动删除文件的脚本 https://www.u-9.cn/jiaoben/perl/99861.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务