通过本文主要向大家介绍了服务器脚本,服务器端脚本语言,服务器脚本语言,samp服务器脚本,我的世界服务器脚本等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
支持匹配路径 匹配文件名 多久没有访问的自动清理
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
</div>

