function drush_invoke_process

8.0.x drush_invoke_process($site_alias_record, $command_name, $commandline_args = array(), $commandline_options = array(), $backend_options = TRUE)
6.x drush_invoke_process($site_alias_record, $command_name, $commandline_args = array(), $commandline_options = array(), $backend_options = TRUE)
7.x drush_invoke_process($site_alias_record, $command_name, $commandline_args = array(), $commandline_options = array(), $backend_options = TRUE)
4.x drush_invoke_process($site_alias_record /*, $command_name, $commandline_args = array(), $commandline_options = array(), $backend_options = array() */)
5.x drush_invoke_process($site_alias_record, $command_name, $commandline_args = array(), $commandline_options = array(), $backend_options = TRUE)
master drush_invoke_process($site_alias_record, $command_name, $commandline_args = array(), $commandline_options = array(), $backend_options = TRUE)

Invoke a command in a new process, targeting the site specified by the provided site alias record.


array $site_alias_record: The site record to execute the command on. Use '@self' to run on the current site.

string $command_name: The command to invoke.

array $commandline_args: The arguments to pass to the command.

array $commandline_options: The options (e.g. --select) to provide to the command.

mixed $backend_options: TRUE - integrate errors FALSE - do not integrate errors array - @see drush_backend_invoke_concurrent There are also several options that _only_ work when set in this parameter. They include: 'invoke-multiple' If $site_alias_record represents a single site, then 'invoke-multiple' will cause the _same_ command with the _same_ arguments and options to be invoked concurrently (e.g. for running concurrent batch processes). 'concurrency' Limits the number of concurrent processes that will run at the same time. Defaults to '4'. 'override-simulated' Forces the command to run, even in 'simulated' mode. Useful for commands that do not change any state on the machine, e.g. to fetch database information for sql-sync via sql-conf. 'interactive' Overrides the backend invoke process to run commands interactively. 'fork' Overrides the backend invoke process to run non blocking commands in the background. Forks a new process by adding a '&' at the end of the command. The calling process does not receive any output from the child process. The fork option is used to spawn a process that outlives its parent.

Return value

If the command could not be completed successfully, FALSE. If the command was completed, this will return an associative array containing the results of the API call. @see drush_backend_get_result()

Do not change the signature of this function! drush_invoke_process is one of the key Drush APIs. See

Related topics

27 calls to drush_invoke_process()
backendUnitCase::testBackendFork in tests/backendUnitTest.php
Covers the following target responsibilities.
DrushCommand::execute in lib/Drush/Psysh/DrushCommand.php
drush_archive_dump in commands/core/
Command callback. Generate site archive file.
drush_archive_restore in commands/core/
Command callback. Restore web site(s) from a site archive file.
drush_browse in commands/core/
Command callback.

... See full list


includes/, line 104
The drush command engine.


function drush_invoke_process($site_alias_record, $command_name, $commandline_args = array(), $commandline_options = array(), $backend_options = TRUE) {
  if (is_array($site_alias_record) && array_key_exists('site-list', $site_alias_record)) {
    list($site_alias_records, $not_found) = drush_sitealias_resolve_sitespecs($site_alias_record['site-list']);
    if (!empty($not_found)) {
      drush_log(dt("Not found: @list", array("@list" => implode(', ', $not_found))), LogLevel::WARNING);
      return FALSE;
    $site_alias_records = drush_sitealias_simplify_names($site_alias_records);
    foreach ($site_alias_records as $alias_name => $alias_record) {
      $invocations[] = array(
        'site' => $alias_record,
        'command' => $command_name,
        'args' => $commandline_args,
  else {
    $invocations[] = array(
      'site' => $site_alias_record,
      'command' => $command_name,
      'args' => $commandline_args,
    $invoke_multiple = drush_get_option_override($backend_options, 'invoke-multiple', 0);
    if ($invoke_multiple) {
      $invocations = array_fill(0, $invoke_multiple, $invocations[0]);
  return drush_backend_invoke_concurrent($invocations, $commandline_options, $backend_options);