Shell Script Rollup 2 delete files that have been created for more than 32 days
#!/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 directorydirsize= ' 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 ];thencd $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
#
This article is from the "Frog Technology Archive" blog, so be sure to keep this source http://frogtwo.blog.51cto.com/3805708/1937267
Shell Script Rollup 2 delete files that have been created for more than 32 days