# 自动清除15天前的日志脚本

\#!/bin/bash

\#0 1 \* \* \* /home/shuncom/auto\_del\_sz\_log.sh

\# 设置变量  
target\_dir="/home/shuncom/services/log/sz\_server"  
log\_file="/home/shuncom/log/del\_driver\_log.log"  
current\_time="$(date '+%Y-%m-%d %H:%M:%S')"

\# 执行删除操作并记录日志  
echo "\[$current\_time\] Start deleting files older than 15 days in $target\_dir" &gt;&gt; "$log\_file"

find "$target\_dir" -type f -mtime +15 -print -delete &gt;&gt; "$log\_file" 2&gt;&amp;1

echo "\[$current\_time\] Deletion complete." &gt;&gt; "$log\_file"  
echo "---------------------------------------------" &gt;&gt; "$log\_file"