Execute wp-cli command on all sites on server

Here’s an example using find with a directory type and zero maxdepth: $ find /srv/users/serverpilot/apps/*/public/ \ -type d \ -maxdepth 0 \ -exec /usr/local/bin/wp core update –path={} \; or in a single line: $ find /srv/users/serverpilot/apps/*/public/ -type d -maxdepth 0 -exec /usr/local/bin/wp core update –path={} \;

WP-CLI alias: connect with ssh proxy

I created simillar configuration to yours and proxy is working for me. My config looks like: Host production HostName xxx.xxx.xxx.xxx ProxyCommand ssh -q -W %h:22 vagrant ForwardAgent yes Host vagrant HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /path/to/.vagrant/machines/default/virtualbox/private_key IdentitiesOnly yes ForwardAgent yes LogLevel FATAL I’m treating my vagrant local … Read more

WP-CLI Get Site ID from its url

It looks like –url isn’t working to filter the wp site list output. So instead one could try: wp site list | awk ‘{ if( $2 == SITE_URL_STRING ) print $1; }’ where we use the awk trick from here, to filter the url column and display the blog_id column. Here we must replace SITE_URL_STRING … Read more

wp-cli silently fails with 255 when running wp core install

I was missing some php extensions that wp-cli and/or WordPress needed but there is no error output stating as much. I’m guessing it was specifically the missing mysqli extension. I used a WP-CLI command to test the base container for missing extensions and now I have sudo docker-php-ext-install gd sockets mysqli exif in my config.yml. … Read more

How to run nested xargs commands?

xargs is unnecessary, something similar to this will do the job without any piping or xargs: sites=$(wp site list –field=url) for site in $sites do users=$(wp user list –url=”$site” –role=subscriber) for user in $users do wp user delete $user –url=”$site” –reassign=4 end end

how do you use Wp-cli on Shared Hosting? [closed]

the default instructions assume you have root and are intended to provide the most convenient use by placing the phar package in your path alternative 1: remove the sudo, change /usr/local/bin/wp to /path/to/your/installation/wp, and instead of calling the commands with wp command <parameters> use ./wp command <parameters> alternative 2: remove the sude, change /usr/local/bin/wp to … Read more