How do you kill WP-CLI execution?

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x