shell find 删除超过30天的文件和目录

#!/bin/bash 
location="/root/sqlbak/"  
find $location -mtime +30 -type d |xargs rm -rf   #删除目录
find $location -mtime +30 -type f |xargs rm -f   #删除文件
find $location -mtime +30 |xargs rm -rf   #删除目录及文件
find $location -mtime +30 -name "*.gz" | xargs rm -f #还可以做过滤后删除

  

posted @ 2019-07-31 09:57  lililili——  阅读(2704)  评论(0)    收藏  举报