删除今天之间的日志文件
find /path/to/logs -type f ! -newermt "$(date +%Y-%m-%d)" -exec rm {} \;
=====================================
这个命令会在/path/to/log/files目录下查找所有扩展名为.log的文件,并检查它们的时间戳,如果时间戳超过7天,则删除这些文件。
配置crontab 表达式,每天凌晨两点执行
0 2 * * * find /path/to/log/files -type f -name "*.log" -mtime +7 -exec rm -f {} \;