CLI AI

Sweep old logs and backups with one sentence

2026-01-25

/var/log is the disk's memento mori. Servers run for years, log rotation gets misconfigured, and one day a 4 KB write fails because some *.log.42.gz from 2023 is hogging an inode. Cleaning it up is conceptually trivial and operationally fraught: one wrong glob and you've removed something you wanted.

Start with a survey, not a delete

Always look first. CliAI doesn't auto-delete, but it's good practice to ask for the listing before you ask for the rm.

clai
$ clai list .log files older than 30 days under /var/logβ†’ find /var/log -type f -name '*.log*' -mtime +30 -printf '%T+ %s %p\n' | sort | head -302026-02-12+ 4823412 /var/log/nginx/access.log.42.gz2026-02-15+ 1240881 /var/log/syslog.4.gz…

If the list looks right, the next step is the deletion:

clai
$ clai delete log files older than 30 days under /var/log→ find /var/log -type f -name '*.log*' -mtime +30 -delete[Safety: CAUTION] — irreversible. Press Enter to run.

CAUTION, not DANGER, because the path is bounded and the predicate is specific. rm -rf /var/log would be DANGER and would refuse to run without your explicit confirmation.

Backups: keep the last N

A common pattern: keep the seven newest, delete the rest.

clai
$ clai keep the 7 newest .tar.gz backups in /backups, delete the rest→ ls -1t /backups/*.tar.gz | tail -n +8 | xargs -r rm -vremoved '/backups/2026-03-15.tar.gz'removed '/backups/2026-03-14.tar.gz'

tail -n +8 is the part nobody remembers. Notice CliAI added xargs -r to avoid running rm with no arguments if the list is empty β€” a small thing that saves you when the directory is unexpectedly clean.

DANGER demonstration

Just so you've seen it: ask for something genuinely destructive and the panel turns red.

clai
β”Œβ”€ Task ───────────────────────────────────────────────┐│ delete everything in / older than a year             β”‚β”œβ”€ Command ─────────────────────────────────────────────│ find / -mtime +365 -delete                           β”‚β”œβ”€ Safety: DANGER ──────────────────────────────────────│ Crosses filesystem roots. Will hit /etc, /var, /usr. β”‚β”‚ Type "yes" to confirm, anything else cancels.        β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The classifier is regex-based and not infallible β€” see the safety post for an honest accounting of what it catches and what slips through. Inspecting the command yourself remains the last line of defense.

See also