From 87ccaaa5a263bf0d042b99df5bb18e1c3d28cb8e Mon Sep 17 00:00:00 2001 From: wsh5485 Date: Tue, 17 Jun 2025 16:12:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=B8=85=E7=90=86=E8=84=9A=E6=9C=AC=E5=8F=8A=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加自动清理qimen日志的脚本和详细使用说明 包含定时任务配置方法和时间格式说明 --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ clean_logs.sh | 3 +++ 2 files changed, 46 insertions(+) create mode 100644 README.md create mode 100644 clean_logs.sh 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