commit 87ccaaa5a263bf0d042b99df5bb18e1c3d28cb8e Author: wsh5485 Date: Tue Jun 17 16:12:15 2025 +0800 feat: 添加日志清理脚本及使用说明文档 添加自动清理qimen日志的脚本和详细使用说明 包含定时任务配置方法和时间格式说明 diff --git a/README.md b/README.md new file mode 100644 index 0000000..88f61e3 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# 日志清理脚本使用说明 + +## 脚本功能 +本脚本用于自动清理 `/home/data/www/ipos/logs/qimen_log/` 目录下的 `.txt` 日志文件。 + +## 使用方法 +1. 将脚本上传到服务器 +2. 给脚本执行权限: +```bash +chmod +x /path/to/clean_logs.sh +``` +3. 测试脚本运行: +```bash +/path/to/clean_logs.sh +``` + +## 设置定时任务 +1. 编辑crontab: +```bash +crontab -e +``` +2. 添加定时任务(每天22点执行): +``` +0 22 * * * /path/to/clean_logs.sh +``` + +## 自定义执行时间 +crontab时间格式说明: +``` +* * * * * +- - - - - +| | | | | +| | | | +----- 星期几 (0 - 6) (周日=0) +| | | +---------- 月份 (1 - 12) +| | +--------------- 日 (1 - 31) +| +-------------------- 小时 (0 - 23) ++------------------------- 分钟 (0 - 59) +``` + +示例: +- 每天10:30执行:`30 10 * * *` +- 每周一8:00执行:`0 8 * * 1` +- 每月1日午夜执行:`0 0 1 * *` \ No newline at end of file diff --git a/clean_logs.sh b/clean_logs.sh new file mode 100644 index 0000000..7c4b662 --- /dev/null +++ b/clean_logs.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# Clear qimen logs at 10pm daily +find /home/data/www/ipos/logs/qimen_log/ -type f -name "*.txt" -delete \ No newline at end of file