亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

服務(wù)器自動刪除文件的腳本

 更新時間:2013年08月22日 18:47:17   作者:  
加入系統(tǒng) 計劃程序中,自動清理垃圾文件,如不需要的日志文件,需要的朋友可以參考下

支持匹配路徑 匹配文件名  多久沒有訪問的自動清理

復(fù)制代碼 代碼如下:

#用于各系統(tǒng)清理文件腳本,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

相關(guān)文章

最新評論