1

I am experimenting with WP-CLI on Windows 10 and XAMPP. I probably don't understand how it works, because I expected stopping Apache from the XAMPP Control Panel would stop WP-CLI script execution on the command line.

I have a long running script in a plugin class with a progress bar. I started running it, and then decided I wanted to make some modifications. I stopped Apache and MySQL from the control panel, and the progress bar kept going. It seemed like the script did not stop running.

Does WP-CLI "run" it's own server of some kind? Is it possible to kill all running processes in WP-CLI?

1
  • Do you see the WP CLI process in the task manager?
    – kero
    Feb 8, 2021 at 12:59

1 Answer 1

2

I stopped Apache and MySQL from the control panel, and the progress bar kept going. It seemed like the script did not stop running.

Correct, WP CLI has nothing to do with Apache, Apache serves browser requests. MySQL might be used by WP CLI, but WP CLI doesn't run on MySQL. A kitchen doesn't cease to exist if you remove the fridge.

Does WP-CLI "run" it's own server of some kind?

No, there are no servers here, that's not how WP CLI and command line programs work.

WP CLI is a PHP command line tool, PHP is running the same way any other command runs, and is exited the same way any other command is exited.

You abort WP CLI commands the same way you would any other CLI command:

  • cmd + c on a Mac
  • ctrl + c on other platforms
  • closing the terminal
  • Task Manager ( php.exe? )

Remember, there is no server, no browser request, no URL, no cookies, no current user, no HTTP headers, because there is no browser, no server, it's just PHP code directly running on a computer. It's just another program the same as rsync, cmd.exe, or even msword.exe.

2
  • Thanks, makes total sense! So if I start a long process, closing the terminal will abort it? I know you wrote that specifically, but just to be sure! I tried CTRL + C, but nothing seemed to happen for me.
    – TASan
    Feb 9, 2021 at 4:48
  • 1
    In most cases yes, assuming it didn't spawn sub-programs, as for the exact key command, I'm a Mac user and we use cmd + c, and on Linux it's ctrl + c, if they don't work then you'll need to google what Windows uses. Also sometimes it doesn't work immediatley. The only foolproof method that works 100% of the time is task manager
    – Tom J Nowell
    Feb 9, 2021 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.