我有以下WP-CLI命令来更新所有插件和核心。从cron执行时,它似乎失败了(其他cron命令工作):
0 0 * * 0 for dir in /var/www/html/*/; do cd "$dir" && wp plugin update --all --allow-root; wp core update --allow-root; done
我尝试手动运行它(在一段时间没有更新后从GUI手动更新后,我这样做了),我得到了所有站点的以下信息:
Success: Plugin already updated.
Success: WordPress is up to date.
为什么cron上的命令会失败?
我试图通过让命令每分钟运行来调试它(* * * * *
) 并检查输出(cron输出通常转到/var/mail/root
).
/变量/邮件/根输出:
Subject: Cron <root@machine_name> for dir in /var/www/html/*/; do cd "$dir" && wp plugin update --all --allow-root; wp core update --allow-root; done
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
Message-Id: <20170723050601.E8FBF3EF4F@machine_name>
Date: Sun, 23 Jul 2017 05:06:01 +0000 (UTC)
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found
/bin/sh: 1: wp: not found