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

前端之家收集整理的这篇文章主要介绍了shell脚本汇总 2 删除创建时间超过32天的文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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


#!/bin/bash
#date:2017-04-11
#version:clear_ballcloud_back_v1.0
#contents:removingthe/www/web/ballcloud_bakck/*,ifthefileiscreatedabove32day
#

cd/www/web

#sumthesizeofalreadydeletedirectory

dirsize=`du-sbackup_ballcloud|awk'{print$1}'`

#
#definethereadytodeldirectory
#

maxsize=$((20000))

cleardir="/www/web/backup_ballcloud"

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


#
#deleteallof/www/web/ballcloud_back/*
#


if[$dirsize-gt$maxsize];then

	cd$cleardir&&find.-mtime+32-typed|xargsrm-rf&>/dev/null;
fi


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

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

if[$emptyFolder-gt0];then

	cd$cleardir&&find.-mtime+32-typed|xargsrm-rf&>/dev/null;
fi


#

原文链接:https://www.f2er.com/bash/392686.html

猜你在找的Bash相关文章