clearLog_New_v2.sh
作者:互联网
#!/bin/sh #@author lixiaoguang1 function deleteLog(){ local path pathList #path 为输入的路径 path=$1 #pathList为按照log条件检索的结果 pathList=$(find ${path} -name "*.log" -o -name "*.out" -o -name "*.log.*") for temp in ${pathList} do #判断文件的读取时间是否大于3天 #deleFileList为0,表示不大于3天,则覆盖重写文件 #不为0,文件则执行删除 deleFileList=$(find $temp -mtime +3 ) if test -z "$deleFileList" then echo "返回结果0,执行重写:"${temp} echo "日志清理工具执行清理操作,如有问题请联系:lixiaoguang10" > ${temp} else echo "返回结果不为0,执行删除" ${temp} rm -f ${temp} fi done } if test -d $1 then deleteLog $1 elif test -f $1 then echo "不是目录!" exit 1 else echo "目录或文件不存在!"
标签:log,temp,clearLog,pathList,echo,v2,path,test,New 来源: https://www.cnblogs.com/newface/p/10882618.html