我有一个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
这是可以使用的最短模式吗? 你会怎么做?
为什么同一个循环三遍而不是您的示例中的一遍?
乍一看,我不知道如何缩短时间,也不知道为什么。
If anything, the script could get better (and thus longer) by improving the detection of WordPress (if needed). Also, I'd probably run
wp language core update
as well to make sure translations are up-to-date.