首页 > 系统服务 > 详细

shell脚本汇总 2 删除创建时间超过32天的文件

时间:2017-06-15 22:31:06      阅读:301      评论:0      收藏:0      [点我收藏+]

shell脚本汇总 2 删除创建时间超过32天的文件


#!/bin/bash
#date:2017-04-11
#version:clear_ballcloud_back_v1.0
#contents: removing the  /www/web/ballcloud_bakck/* , if the file is created above 32 day
#

cd /www/web

#sum the size of already delete directory

dirsize=`du -s backup_ballcloud | awk ‘{print $1 }‘ `

#
#define the ready to del directory
#

maxsize=$((20000))

cleardir="/www/web/backup_ballcloud"

echo -e "Allowd maxsize:$maxsize \n" ;


#
# delete all of /www/web/ballcloud_back/*
#


 if [ $dirsize -gt $maxsize ];then

	cd $cleardir && find .  -mtime +32 -type d | xargs rm -rf  &> /dev/null;
 fi

 
#
#Defin emptyFolder= `ls /www/web/backup_ballcloud | wc -l `
#

emptyFolder=` ls /www/web/backup_ballcloud | wc -l `

if [ $emptyFolder -gt 0 ];then

	 cd $cleardir && find . -mtime +32 -type d | xargs  rm -rf  &> /dev/null;
fi


#

本文出自 “Frog的技术归档” 博客,请务必保留此出处http://frogtwo.blog.51cto.com/3805708/1937267

shell脚本汇总 2 删除创建时间超过32天的文件

原文:http://frogtwo.blog.51cto.com/3805708/1937267

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!