标签:round style b2b done str 查找 删除日志 mtime 空格
话不多少,直接上代码:
#!/bin/bash
workdir=("/home/Tax_Punish_Ret/log_txt") #可填写多个路径, 用空格隔开
# 查找日志文件
for wdir in ${workdir[@]}
do
echo filepath is $wdir
if [ $wdir = ${workdir[0]} ] ;then
fileStr=`find $wdir/*.log`
echo files is $fileStr
else
fileStr=`find $wdir -type d`
echo filee is $fileStr
fi
# 删除/清空日志文件
for dir in $fileStr
do
echo file name is $dir
# 清空不删除日志文件
echo ‘‘>$dir
# 删除日志文件
#find $dir -name ‘*log*‘ -and -mtime +7 -type f | xargs rm
if [ $? -eq 0 ];then
echo $date delete $dir success!
else
echo $date delete $dir FAILD!
fi
done
done
标签:round style b2b done str 查找 删除日志 mtime 空格
原文地址:https://www.cnblogs.com/fanjp666888/p/10307634.html