clean-logs Command
Last updated January 14, 20262 min read
The clean-logs command removes old log files to free up disk space. Use this periodically if you run the CLI frequently and want to manage storage usage.
Usage
hooklistener clean-logs [OPTIONS]Options
| Option | Description |
|---|---|
--older-than <DAYS> | Delete logs older than N days (default: 7) |
--all | Delete all log files regardless of age |
--dry-run | Show what would be deleted without actually deleting |
--help | Show help information |
Log Location
Log files are stored in:
- macOS/Linux:
~/.config/hooklistener/logs/ - Windows:
%APPDATA%\hooklistener\logs\
Each CLI session creates a new log file with a timestamp. Over time, these can accumulate and use disk space.
Examples
Clean Old Logs (Default)
Remove logs older than 7 days:
hooklistener clean-logsOutput:
Found 12 log files older than 7 days
Deleted 12 files, freed 45.2 MBPreview Before Deleting
See what would be deleted without actually removing files:
hooklistener clean-logs --dry-runOutput:
[DRY RUN] Would delete 12 log files (45.2 MB):
- hooklistener-2026-01-01.log (3.2 MB)
- hooklistener-2026-01-02.log (4.1 MB)
- hooklistener-2026-01-03.log (2.8 MB)
...Clean Logs Older Than 30 Days
Keep more history by only deleting older files:
hooklistener clean-logs --older-than 30Delete All Logs
Remove all log files to start fresh:
hooklistener clean-logs --allWarning:Using --all removes all logs including recent ones. Consider running diagnostics first if you're experiencing issues.
Automation
You can automate log cleanup with a cron job or scheduled task:
macOS/Linux (cron)
# Add to crontab (crontab -e)
# Run weekly on Sunday at midnight
0 0 * * 0 hooklistener clean-logs --older-than 14Windows (Task Scheduler)
Create a scheduled task that runs hooklistener clean-logs weekly.
Related Commands
diagnostics— Generate a diagnostic bundle before cleaning logs- CLI Getting Started — Logging configuration and options