AGENT SKILL
log-rotate-pro
智能日志轮转与归档工具,支持压缩、保留策略、定时清理和磁盘空间监控。适用于生产环境日志管理。
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- log-rotate-pro
- author
- ops-toolkit
- license
- MIT
- version
- 1.2.0
- description
- 智能日志轮转与归档工具,支持压缩、保留策略、定时清理和磁盘空间监控。适用于生产环境日志管理。
02 资源文件 3
- 参考文档_provenance.json1.2 KB
- 参考文档requirements.txt11 B
- 脚本rotate.py10.0 KB
03 SKILL.md 正文
Log Rotate Pro
高效、安全的日志轮转工具,自动管理日志文件的生命周期。
功能特性
- 基于大小和时间的轮转策略
- gzip 压缩归档
- 保留策略(按数量/大小/天)
- 磁盘空间低水位告警
- 支持通配符匹配与目录递归扫描
- 支持 dry-run 模式
安装
pip install -r requirements.txt
快速开始
python rotate.py --config config.yaml
参数说明
| 参数 | 说明 |
|---|---|
--config |
配置文件路径(YAML) |
--dry-run |
只打印将执行的操作,不实际执行 |
--verbose |
输出详细日志 |
--scan-dir |
直接指定要扫描的目录(覆盖配置) |
配置示例
# config.yaml
rotation:
max_size: 100MB
max_age_days: 30
compress: true
pattern: "*.log"
recursive: true
retention:
keep_num: 10
keep_size: 1GB
alert:
disk_threshold_percent: 80
工作原理
- 读取配置
- 扫描匹配的日志文件
- 按策略计算需要轮转的文件
- 执行压缩与归档
- 清理过期文件
- 输出操作摘要
安全说明
本工具不会主动访问网络。所有操作均在本地文件系统执行。dry-run 模式下不执行任何修改操作。
开发
# 运行测试
python -m pytest tests/
许可
MIT License
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
★ 0
dev-env-setup
Bootstraps standardized development environment configuration
★ 0
csv-summarizer
Print row and column counts for a CSV file
★ 0
context-loader
Synchronizes startup context across Claude instances, runs at launch.
★ 0
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
★ 0
data-processor
Process data with custom algorithms
★ 0