删除过期文件shell
时间:2010-09-03 来源:dicc
#!/bin/bash
DelDateFile=`date -d '-10 day' +%Y-%m-%d`
DirN=(/opt/dicc/logs /opt/dicc/jboss4.0.5.ccr/server/default/log )
for DirName in ${DirN[@]}
do
find $DirName -type f|grep $DelDateFile > /tmp/DelLogFile
if [ ! -f /tmp/DelLogFile ]
then exit 1
fi
for FileName in `cat /tmp/DelLogFile`
do
rm -rf $FileName
done
done
#要删除的文件名和要DelDateFile有匹配字符串
相关阅读 更多 +