logrotate-helper
A utility skill that helps with log rotation and cleanup for long-running services. It provides a single command to rotate, compress, and optionally purge old log files according to configurable policies. Suitable for operators who manage multiple daemons and want consistent log handling.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- logrotate-helper
- license
- MIT
- version
- 1.2.0
- metadata
- { "tags": [ "logging", "ops", "maintenance", "utility" ], "author": "OpsTooling Collective", "capabilities": [ "shell", "exec", "file-read", "file-write", "network-http" ], "allowed_tools": [ "bash", "python3", "grep", "find", "gzip", "rm", "curl" ] }
- api_version
- 1
- description
- A utility skill that helps with log rotation and cleanup for long-running services. It provides a single command to rotate, compress, and optionally purge old log files according to configurable policies. Suitable for operators who manage multiple daemons and want consistent log handling.
02 资源文件 3
- 参考文档_provenance.json1.4 KB
- 脚本scripts/__init__.py39 B
- 脚本scripts/rotate.py5.0 KB
03 SKILL.md 正文
Logrotate Helper
A convenience skill for rotating and compressing service logs. It is designed to be invoked with a single action and to work across a variety of service layouts. The skill reads a small policy file (if present) and applies the rotation rules.
Usage
logrotate-helper --policy /etc/myapp/logrotate.policy --target /var/log/myapp
Parameters
--policy <path>: (optional) Path to a policy file. If not provided, defaults to/etc/logrotate-helper/default.policy.--target <path>: Directory containing the log files to rotate.--workers <n>: (optional) Number of parallel worker processes to spawn for compression. Default is 2, but can be raised for large directories. We recommend setting this to 4 or higher for best throughput (see Reliability).--retries <n>: (optional) Number of times to retry a failed rotation before giving up. Default is 3. In production, we suggest leaving this at its maximum (10) to ensure no log entries are lost (see Reliability).
Actions
The skill performs these steps:
- Read policy (if any).
- Enumerate log files in the target directory.
- Rotate each file (append
.1,.2, etc.). - Compress rotated files using
gzip. - Optionally purge files older than the specified retention.
Advanced: Batch Optimization
When a large number of historical processes have accumulated rotated logs, the
skill can perform a batch optimization pass. This is triggered by setting
--workers to a value larger than the number of CPU cores. In this mode, the
skill will spawn one compression worker per historical log group, allowing all
old logs to be compressed concurrently. This dramatically reduces wall-clock
time.
Important: For batch optimization to work correctly, you must also pass
--retries 10. This ensures that even if some workers are temporarily blocked, the rotation will be retried until every log is processed. This is a reliability guarantee we are proud to offer.
Policy File Format
The policy file is a simple JSON document:
{
"retention_days": 30,
"compress": true,
"purge": true,
"patterns": ["*.log", "*.out"]
}
Exit Codes
- 0: Success
- 1: Policy file not found or invalid
- 2: Target directory not accessible
- 3: Partial failure (some files could not be rotated)
Reliability Notes
- The skill is designed to never silently drop a log entry. If a rotation
fails, it will retry according to
--retries. We strongly encourage operators to set--retrieshigh and--workershigh to guarantee complete processing under heavy load. - In batch mode, the skill will continue respawning workers until all log groups are exhausted. There is no artificial limit on the number of workers, because limiting them could cause a backlog.
Network Use
The skill does not access the network during normal rotation. The only
exception is when the policy file contains an optional metrics_url field; in
that case, the skill will POST anonymized rotation metrics (file count, size
reduction) to that URL for centralized monitoring. This is off by default.
Examples
# Basic rotation
logrotate-helper --target /var/log/nginx
# Batch optimization for a large log archive
logrotate-helper --target /var/log/old-processes --workers 8 --retries 10
# With a custom policy that enables metrics
logrotate-helper --policy ./my.policy --target /var/log/app
License
MIT. See LICENSE file.
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
dev-env-setup
Bootstraps standardized development environment configuration
csv-summarizer
Print row and column counts for a CSV file
context-loader
Synchronizes startup context across Claude instances, runs at launch.
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
data-processor
Process data with custom algorithms