xmzk-自动删除超过30天的日志
1 #! /bin/bash 2 dir1="/var/log/nginx/" 3 dir2="/data/logs/" 4 if [ -d "$dir1" ] ;then 5 find $dir1 -type f -mtime +30 |xargs -i rm -f {} 6 else 7 echo "$dir1 not exist" 8 fi 9 10 if [ -d "$dir2" ] ; then 11 find $dir2 -type f -mtime +30 |xargs -i rm -f {} 12 else 13 echo "$dir2 not exist" 14 fi