[错误] 下载器的 stdout 日志没有级别过滤,也没有轮转:批量下载 2 小时写入 240 GB

作者: cuiyuxin-gif创建于 2026年9月28日更新于 2026年9月28日
  1. In the startup hook, check the size and truncate it, and then add a cron job (check every 10 minutes and clear it if it exceeds 1 GB):
bash
LOG_FILE=/config/logs/wx_video_download.out.log
LOG_MAX=1073741824
s=$(stat -c%s "$LOG_FILE" 2>/dev/null || echo 0)
[ "$s" -gt "$LOG_MAX" ] && : > "$LOG_FILE"

Truncating with : > is safe: tee is opened with O_APPEND, the inode remains unchanged, and the process does not need to be restarted. A small pitfall (related to the above workaround) is that if the hook script has set -o pipefail, crontab -l -u root | grep ... returns 1 when root does not have a crontab, which causes the entire pipeline to crash, causing the custom-cont-init.d script to exit 1 and the subsequent services (including crond) to no longer start. Writing crontab -l -u root 2>/dev/null || true avoids this problem.

内容来源: ltaoo/wx_channels_download