Documentation
Forge Pro
WP-CLI & Background Jobs

WP-CLI & Background Jobs

Requirements

WP-CLI tools need the wp command on the server and PHP process functions. If your host disables exec() or proc_open() in php.ini, the tools return a clear error such as "WP-CLI commands cannot run here".

Foreground Commands

wp_run_wp_cli runs one wp command and returns its exit code and output.

command: "plugin list --status=active"

Commands are run as wp <command> --path=<site path>. Shell metacharacters are rejected outright (; & | $ < > ` and line breaks), so only a single command can run.

Background Jobs

Long-running work (imports, search-replace, cache flushes) should not tie up a request.

ToolPurpose
wp_run_wp_cli_backgroundQueues a command and returns a job ID immediately
wp_check_wp_cli_jobReads a job's status and result

Jobs run on WordPress's built-in cron. That means a job starts on the next cron tick, which depends on site traffic or a real system cron calling wp-cron.php. On a quiet staging site, a job can wait until something triggers cron.

Limits

  • wp_run_wp_cli and wp_run_wp_cli_background are limited to 10 calls per minute, separately from the general limit.
  • Both are blocked on production-detected sites unless overridden, and require an Administrator.
  • Every command is written to the audit log in full.

wp forge Terminal Commands

Forge Pro also registers commands you can run yourself, for developers who prefer a terminal.

# Shows the environment, override state, whether power tools are allowed,
# backup acknowledgement, and whether direct live writes are on
wp forge status
 
# Lists recent database and file snapshots
wp forge snapshots --limit=25

These commands register only when WP-CLI is present, and do nothing on normal web requests.