脚本:
#!/bin/bash
for j in `du -h --max-depth=0 /home/zhanghu/*/_package/run/ |grep G|grep -v '/home/zhanghu/$' |awk -F 'G' '{print $1$2}'|awk ' {if($1 > 2 ) {print $2} }'`; do
echo "$j need del";
find $j -type f -mmin +1440 -name "*.log*" | xargs rm -rf;
find $j/audit*/ -type f -mmin +1440 -exec rm -rf {} \;
done
#删除61天以前的包
find /home/qboxserver/*/_fpkgs/ -type f -mtime +60| xargs rm -rf
echo "DONE"
说明:
通过awk获取大小和路径,>2G 执行rm操作
1440表示24小时
待研究cron自动执行:
bash /home/zhanghu/clearlog/_package/clearlog.sh