Is there a way to update plugins, themes, and core, all in one row, instead 3 rows, in WPCLI?

This is the current code I use in the crontab and that I’d like to improve:

0 0 * * * for dir in /var/www/html/*/; do cd "$dir" && /usr/local/bin/wp plugin update --all --allow-root; done
0 0 * * * for dir in /var/www/html/*/; do cd "$dir" && /usr/local/bin/wp core update --allow-root; done
0 0 * * * for dir in /var/www/html/*/; do cd "$dir" && /usr/local/bin/wp theme update --all --allow-root; done

2 Answers
2

Run a script instead:

0 0 * * * for dir in /var/www/html/*/; do cd "$dir" && ./updatewp.sh; done

In updatewp.sh:

wp core update --all --allow-root
wp plugin update --all --allow-root
wp theme update --all --allow-root

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *