WP-CLI: `action-scheduler action`
This reference documents the wp action-scheduler action subcommands implemented in classes/WP_CLI/Action_Command.php and classes/WP_CLI/Action/*.
Subcommands
list— Query scheduled actions (supports allas_get_scheduled_actions()args).get— Get details for a single action.logs— Show log entries for an action.create— Schedule a new action (single, recurring, cron, or async).generate— Create multiple single actions with an interval.run— Run specific action IDs immediately.delete— Delete specific action IDs.cancel— Cancel the next occurrence or all occurrences of a scheduled action.next— Get the next action ID or timestamp for a hook.
list
Get a list of scheduled actions. This maps directly to as_get_scheduled_actions().
Syntax
wp action-scheduler action list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
Arguments
--<field>=<value>: Any argument supported byas_get_scheduled_actions()(e.g.--status=pending,--group=my-group,--per_page=50).--field=<field>: Print the value of a single property for each action.--fields=<fields>: Comma-separated fields to display.--format=<format>:table(default),csv,ids,json,count,yaml.
Default fields
id,hook,status,group,recurring,scheduled_date
Optional fields
args,log_entries
Examples
# List pending actions for a group
wp action-scheduler action list --status=pending --group=action-scheduler
# Get just IDs for later piping
wp action-scheduler action list --status=pending --format=ids
get
Get details for a single scheduled action.
Syntax
wp action-scheduler action get <id> [--field=<field>] [--fields=<fields>] [--format=<format>]
Arguments
<id>: Action ID.--field=<field>: Return only a single field.--fields=<fields>: Comma-separated list of fields to display.--format=<format>:table(default),csv,json,yaml.
Notes
log_entriesis a structured list of logs withdateandmessage.
Example
wp action-scheduler action get 123 --fields=id,hook,status,scheduled_date
logs
Show log entries for a scheduled action. This is a convenience wrapper around get --field=log_entries.
Syntax
wp action-scheduler action logs <id>
create
Create a new scheduled action.
Syntax
wp action-scheduler action create <hook> <start> [--args=<args>] [--cron=<cron>] [--group=<group>] [--interval=<interval>] [--unique] [--priority=<priority>]
Arguments
<hook>: Hook name.<start>: Unix timestamp, orasync/nowto enqueue an async action.--args=<args>: JSON object of callback args. Default:[].--cron=<cron>: Cron expression (crontab.guru format). Default: empty.--group=<group>: Group name. Default: empty.--interval=<interval>: Recurrence interval in seconds. Default:0.--unique: Create only if no identical pending action exists (passed through to scheduler).--priority=<priority>: Action priority. Default:10.
Behavior
- If
--intervalis set, a recurring action is created viaas_schedule_recurring_action(). - If
--cronis set, a cron action is created viaas_schedule_cron_action(). - If
<start>isasyncornow, an async action is enqueued viaas_enqueue_async_action(). - Otherwise, a single action is created via
as_schedule_single_action().
Examples
wp action-scheduler action create hook_async async
wp action-scheduler action create hook_single 1627147598
wp action-scheduler action create hook_recurring 1627148188 --interval=5
wp action-scheduler action create hook_cron 1627147655 --cron='5 4 * * *'
generate
Generate multiple single actions.
Syntax
wp action-scheduler action generate <hook> <start> [--count=<count>] [--interval=<interval>] [--args=<args>] [--group=<group>]
Arguments
<hook>: Hook name.<start>: Unix timestamp for the first action.--count=<count>: Number of actions to create. Default:1.--interval=<interval>: Seconds between actions (can be negative). Default:0.--args=<args>: JSON object of callback args. Default:[].--group=<group>: Group name. Default: empty.
Example
wp action-scheduler action generate test_multiple 1627147598 --count=5 --interval=5
run
Run one or more existing actions by ID.
Syntax
wp action-scheduler action run <id>...
Examples
# Run a single action
wp action-scheduler action run 100
# Run multiple actions
wp action-scheduler action run 100 200
# Run the first five pending actions in a group
wp action-scheduler action run $( wp action-scheduler action list --status=pending --group=action-scheduler --format=ids )
delete
Delete one or more scheduled actions by ID.
Syntax
wp action-scheduler action delete <id>...
Examples
# Delete a single action
wp action-scheduler action delete 100
# Delete multiple actions
wp action-scheduler action delete 100 200
cancel
Cancel the next occurrence or all occurrences of a scheduled action.
Syntax
wp action-scheduler action cancel [<hook>] [--group=<group>] [--args=<args>] [--all]
Arguments
[<hook>]: Hook name.--group=<group>: Group name.--args=<args>: JSON object of callback args. Default:[].--all: Cancel all occurrences (usesas_unschedule_all_actions()), otherwise cancels one occurrence.
Examples
# Cancel the next scheduled action for a hook
wp action-scheduler action cancel my_hook
# Cancel all occurrences for a hook/group
wp action-scheduler action cancel my_hook --group=my-group --all
next
Get the ID (or raw timestamp) of the next scheduled action for a hook.
Syntax
wp action-scheduler action next <hook> [--args=<args>] [--group=<group>] [--raw]
Arguments
<hook>: Hook name.--args=<args>: JSON object of callback args. Default:[].--group=<group>: Group name.--raw: Return rawas_next_scheduled_action()output (timestamp or boolean).
Behavior
- If
--rawis set, returns the raw timestamp (orfalse). - Otherwise, attempts to return the next running action ID; if none, returns the next pending action ID; otherwise warns.
Example
wp action-scheduler action next my_hook --group=my-group