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

OptionDescription
--older-than <DAYS>Delete logs older than N days (default: 7)
--allDelete all log files regardless of age
--dry-runShow what would be deleted without actually deleting
--helpShow 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-logs

Output:

Found 12 log files older than 7 days
Deleted 12 files, freed 45.2 MB

Preview Before Deleting

See what would be deleted without actually removing files:

hooklistener clean-logs --dry-run

Output:

[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 30

Delete All Logs

Remove all log files to start fresh:

hooklistener clean-logs --all

Warning: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 14

Windows (Task Scheduler)

Create a scheduled task that runs hooklistener clean-logs weekly.