WP-CLI Commands (Action Scheduler)

This reference is generated from the Action Scheduler source code. All commands and arguments below are verified in the classes/WP_CLI/ implementation.

Command Overview

Command Purpose
wp action-scheduler run Run queued actions in batches via WP-CLI.
wp action-scheduler clean Clean up completed/canceled/failed actions in batches.
wp action-scheduler fix-schema Register and (re)create Action Scheduler tables schema.
wp action-scheduler action <subcommand> Manage scheduled actions (list/get/run/delete/create/etc.).
wp action-scheduler data-store Print the active data store class.
wp action-scheduler runner Print the active runner class.
wp action-scheduler status Print store, runner, version, and action counts by status.
wp action-scheduler version Print active Action Scheduler version (or all versions).
wp action-scheduler source Print active source path (or all sources).
wp action-scheduler migrate Migrate actions to the DB table store (only when migration is available).

Note: wp action-scheduler migrate is registered only when migration is allowed and not yet complete.

action-scheduler run

Run the Action Scheduler queue via WP-CLI.

Syntax

wp action-scheduler run [--batch-size=<size>] [--batches=<size>] [--cleanup-batch-size=<size>] [--hooks=<hooks>] [--group=<group>] [--exclude-groups=<groups>] [--free-memory-on=<count>] [--pause=<seconds>] [--force]

Arguments

  • --batch-size=<size>: Maximum actions to run per batch. Default: 100.
  • --batches=<size>: Number of batches to run. Default: 0 (run until complete).
  • --cleanup-batch-size=<size>: Maximum number of actions to clean up. Default: --batch-size.
  • --hooks=<hooks>: Comma-separated hooks to run (no spaces). Example: --hooks=hook_one,hook_two.
  • --group=<group>: Only run actions from a specific group.
  • --exclude-groups=<groups>: Comma-separated groups to exclude (ignored when --group is set).
  • --free-memory-on=<count>: Free memory every N actions. Default: 50. 0 disables.
  • --pause=<seconds>: Seconds to pause when freeing memory. Default: 0.
  • --force: Force execution even if the concurrent batch limit is exceeded.

Examples

# Run all pending actions in batches of 100
wp action-scheduler run

# Run only actions for a hook
wp action-scheduler run --hooks=wc_update_product_lookup_tables

# Run only actions in a group, in two batches of 200
wp action-scheduler run --group=action-scheduler --batch-size=200 --batches=2

action-scheduler clean

Run the Action Scheduler queue cleaner.

Syntax

wp action-scheduler clean [--batch-size=<size>] [--batches=<size>] [--status=<status>] [--before=<datestring>] [--pause=<seconds>]

Arguments

  • --batch-size=<size>: Maximum actions to delete per batch. Default: 20.
  • --batches=<size>: Number of batches to run. Default: 0 (run until no eligible actions remain).
  • --status=<status>: Comma-separated statuses to clean (no spaces). Example: --status=complete,failed,canceled.
  • --before=<datestring>: Only delete actions older than this (defaults to 31 days). Examples: --before='7 days ago', --before='02-Feb-2020 20:20:20'.
  • --pause=<seconds>: Seconds to pause between batches. Default: 0.

Examples

# Clean completed and canceled actions older than 31 days
wp action-scheduler clean

# Clean only failed actions older than 7 days
wp action-scheduler clean --status=failed --before='7 days ago'

action-scheduler fix-schema

Force Action Scheduler table schema registration.

Syntax

wp action-scheduler fix-schema

action-scheduler action

Manage scheduled actions. See wp-cli/action.md for full subcommand reference.

Syntax

wp action-scheduler action <subcommand> [options]

action-scheduler data-store

Print the active data store class.

Syntax

wp action-scheduler data-store

action-scheduler runner

Print the active runner class.

Syntax

wp action-scheduler runner

action-scheduler status

Print status and action counts.

Syntax

wp action-scheduler status [--format=<format>] [--fields=<fields>] [--field=<field>]

This prints:

  • Data store class
  • Runner class (marked “(disabled)” if the action_scheduler_run_queue hook is not attached)
  • Latest Action Scheduler version
  • Action counts by status (with oldest/newest dates)

action-scheduler version

Print the active Action Scheduler version or all registered versions.

Syntax

wp action-scheduler version [--all]

action-scheduler source

Print the active source path or all registered sources.

Syntax

wp action-scheduler source [--all] [--fullpath]
  • --all: List all registered sources.
  • --fullpath: Show full paths (default shows paths relative to ABSPATH).

action-scheduler migrate

Migrate actions to the DB tables store (only registered when migration is available).

Syntax

wp action-scheduler migrate [--batch-size=<size>] [--free-memory-on=<count>] [--pause=<seconds>] [--dry-run]

Arguments

  • --batch-size=<size>: Number of actions to process per batch. Default: 100.
  • --free-memory-on=<count>: Free memory every N actions. Default: 50. 0 disables.
  • --pause=<seconds>: Seconds to pause when freeing memory. Default: 0.
  • --dry-run: Report what would be migrated without changing data.

Example

wp action-scheduler migrate --batch-size=200 --dry-run