Console commands

Five commands. --dry-run is on by default in every one of them, because a command that deletes by default is a command that deletes when somebody runs it to see what the arguments are.

nuke/strike/scopes

Lists what this site can be aimed at, with the handles you will need for --sources.

$ php craft nuke/strike/scopes

entries — Entries
  Sections: blog, caseStudies, events, news

categories — Categories
  Category Groups: industries, topics

assets — Assets
  Volumes: images, documents

nuke/strike/fire <scope>

Previews a strike, or runs it. The scope argument defaults to entries.

FlagDefaultMeaning
--dry-run1Report without deleting. Pass --dry-run=0 to run it.
--force0Skip the interactive confirmation. Required for anything non-interactive.
--sourcesallComma-separated source handles — sections, volumes, groups.
--typesallComma-separated entry type handles.
--sitesallComma-separated site handles.
--statusanyAn element status the scope supports.
--updated-beforeA date, or something relative like "-2 years".
--created-beforeSame.
--limitStop after this many elements.
--hard0Bypass the trash.
--backup1Back up the database first.
--purge-history0Remove drafts and revisions permanently.
--delete-relations0Clear relation rows on a soft delete.
--gc1Run garbage collection afterwards.
--note"Console strike"Recorded against the run.

The preview is identical to the control panel’s — same counts, same warnings.

# See what it would do
php craft nuke/strike/fire entries --sources=caseStudies --updated-before="-2 years"

# Do it, with a prompt
php craft nuke/strike/fire entries --sources=caseStudies --updated-before="-2 years" --dry-run=0

# Do it, from a script
php craft nuke/strike/fire entries --sources=caseStudies --updated-before="-2 years" \
  --dry-run=0 --force --note="Q3 archive cleanup, ticket OPS-482"

Exit codes

  • 0 — nothing to do, a dry run, or a strike that finished cleanly.
  • 1 (SOFTWARE) — the strike ran but some deletions failed.
  • 65 (DATAERR) — the target was refused: a protected scope, a Single, past the ceiling.
  • 64 (USAGE) — no such scope.
  • 78 (CONFIG) — console strikes are switched off.

nuke/sweep/list

Every housekeeping task, grouped, with a filled dot for the ones switched on.

nuke/sweep/run

FlagDefaultMeaning
--dry-run1Scan without removing.
--onlyall enabledComma-separated sweeper handles.
# What would a sweep find?
php craft nuke/sweep/run

# Sweep everything that's switched on
php craft nuke/sweep/run --dry-run=0

# Just the disk hogs
php craft nuke/sweep/run --only=backups,logs,compiled,temp --dry-run=0

Exits non-zero if any task failed, so a deploy step can stop on it.

nuke/sweep/due

Runs the scheduled sweep, but only if the schedule says one is owed. Pro only. Meant for a crontab that fires often, where the schedule lives in Nuke’s settings rather than in cron:

*/15 * * * * cd /path/to/site && php craft nuke/sweep/due --dry-run=0

Exits 0 whether or not anything was due. --dry-run applies here too and is on by default, so the flag is what makes the crontab line real — without it you get a preview and the sweep stays owed.

A note about the queue

None of these push to the queue; they do the work in the process you started. That is what you want from cron and from CI. To run something in the background, use the control panel’s run in the background switch, or push the job yourself.