#!/bin/sh
for i in `ls /vm/vm/ |grep -P 'drop$'`
do
now=$(date +%s)
droptime=$(date -d "$(echo $i | awk -F . '{print $2 " " $3}')" +%s)
n=$(($now - $droptime))
if [ "$n" -ge "259200" ];then
rm -rf /vm/vm/$i
fi
done
ls /vm/vm
S140112.2013-05-29.12:10:36.drop S140112.2013-06-21.12:10:36.drop S140112.2013-06-24.12:10:36.drop S987602
S010730.2013-06-05.13:43:26.drop S140112.2013-06-19.12:10:36.drop S140112.2013-06-22.12:10:36.drop S140112.2013-06-25.12:10:36.drop S987620
S140112 S140112.2013-06-20.12:10:36.drop S140112.2013-06-23.12:10:36.drop S231232
删除时间大于三天的文件夹。
本文转自 freeterman 51CTO博客,原文链接:http://blog.51cto.com/myunix/1229469,如需转载请自行联系原作者