自动升级文档根目录(> = 4.7.x)下的所有WordPress实例的最快捷方法

我有一个Ubuntu 16.04 Nginx环境,其中包含一些最小的WordPress网站(实际上全部具有多达5个常规插件,10个页面,10个图像以及一个仅发送文本数据的简单联系表单)。

I daily execute the script cron_daily.sh with the following three loops, from crontab, to update all WordPress apps under document root. The script uses the WP-CLI shell extension.

for dir in ${drt}/*/; do cd ${dir} && wp plugin update --all --allow-root; done
for dir in ${drt}/*/; do cd ${dir} && wp core update --allow-root; done
for dir in ${drt}/*/; do cd ${dir} && wp theme update --all --allow-root; done

${drt} is document root. It was already declared outside permanently, with its file sourced.

我正在寻找一种将这三个循环的行为合并为一个片段的方法。

This pattern seems promising, and is based on this example:

for dir in ${drt}/*/; do
    if pushd ${dir}; then
        wp plugin update --all --allow-root
        wp core update --allow-root
        wp theme update --all --allow-root
        popd
    fi
done

这是可以使用的最短模式吗? 你会怎么做?