#!/bin/bash keep_time=30 service_log_path=/data/dockers/clogs/service/ service_list=`ls ${service_log_path}` now_time=`date -d "n days ago" +%y%m%d` for service in ${service_list};do service_dir=${service_log_path}${service} del_file_list=`find ${service_dir} -type f -mtime +${keep_time} ;` for del_file in ${del_file_list} ;do # echo [${now_time}] [delete] [${del_file}] rm -rf ${del_file} done done