Shell script for multiple wordpress with wp-cli

I am working on a shell script for execute wp-cli commands on all my wordpress. This is the script:

cd "/var/www/vhosts"
for domain in *
do
  cd /var/www/vhosts/$domain 

  HAS_HTTPDOCS=`find . -name httpdocs | wc -l`
    if test $HAS_HTTPDOCS-gt "0"
    then
    cd httpdocs
    IS_BLOG=`find . -name wp-content | wc -l`
    if test $IS_BLOG -gt "0"
    then
        cd /var/www/vhosts/$domain /httpdocs/
        echo "####### "$domain " #########"
        wp $1 --allow-root  
  fi
  fi
done

But when I execute the sh, in some cases wp-cli return a “cached value”. For example:

Read More

./multitaskWP.sh “option get siteurl”

Result:

##### domain1 ######
domain1.com
##### domain2 ######
domain2.com
##### domain3 ######
domain2.com
##### domain4 ######
domain2.com

This script return the same value for different wordpress domains, is there a cache for the execution of wp-cli in an ubuntu?

Thanks in advance

Related posts

Leave a Reply