Running WP CLI in bulk across WP apps, or running them remotely?
-
Hello,
I'm using MainWP for managing my sites remotely and it works well in most cases, however there's been the odd time where for various reasons I had wanted to run some WP CLI commands either in bulk or at least remotely... was just curious if anyone has accomplished something like that before. Currently MainWP doesn't allow for remotely executing WP CLI commands (though I filed a feature request for them so maybe that'll be added in the distant future).
Example: I want to run
wp media regenerate --yes
(https://developer.wordpress.org/cli/commands/media/regenerate/) across all my websites using WP CLI to regenerate all thumbnails and their sizes. -
Hi @d19dotca,
Yes, it is possible, and with n8n it is easy.
You just need to have SSH access to each website you want to manage to run the WP-CLI command you want. In Cloudron, since there is no external SSH access to the application, you have to identify the container ID that corresponds to the website, in order to run a
docker exec
.docker exec CONTAINERID wp media regenerate --yes
In this example workflow from n8n you can see how you can do all the actions you want, executing them manually, through a cron or with the trigger you want.