#!/bin/sh to_clear_dir=(1 2 3 4 5) function cleanlog () { for item in ${to_clear_dir[@]}; do dir="/root/telephony-mock-server-"$item"/log/" echo "开始删除系统目录: "$dir" 下前三天日志" >> /root/cron_task/task.log time=`date +%T` echo 该任务执行时间:`date +%Y-%m-%d` ${time} >> /root/cron_task/task.log echo "删除日志清单列表:" >> /root/cron_task/task.log find $dir -mtime +2 -name "*log*" >> /root/cron_task/task.log find $dir -mtime +2 -name "*log*" -exec rm -f {} \; echo "----------删除成功!-----------" >> /root/cron_task/task.log done } cleanlog
|