Wordpress wp-cron.php 执行不起作用

问题描述 投票:0回答:3

我有一个多站点 WordPress。 我使用 WP Offload SES Lite 来发送电子邮件。 有一天电子邮件停止工作。

在 wp-ses 中,我看到很多邮件都排在队列中。 发送测试电子邮件没有问题。

调查问题后,我发现 wp-cron.php 不起作用。 我尝试调试它并手动运行 wp-cron,并且没有与 cron 或 ses 相关的错误。 好像跑不了了

尝试禁用 cron 并激活备用 cron,如下所示:

define('DISABLE_WP_CRON', true); /** Use alternate WP_CRON method with
redirects. */ define('ALTERNATE_WP_CRON', true);

从 cli 和 url,通过浏览器和 Wget 运行它。

没什么。 它在更新后一周左右开始发生。

我设置调试:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

这是我在运行 wp-cron 时看到的错误:

[30-Jan-2021 22:13:12 UTC] PHP Notice:  Undefined index: HTTP_HOST in /var/app/current/wp-includes/ms-settings.php on line 57
[30-Jan-2021 22:13:12 UTC] PHP Notice:  Undefined index: HTTP_HOST in /var/app/current/wp-content/plugins/contact-form-7-redirection-pro/classes/class-updates.php on line 71
[30-Jan-2021 22:13:13 UTC] PHP Warning:  array_merge(): Expected parameter 2 to be an array, bool given in /var/app/current/wp-content/themes/my-theme/admin/fields.php on line 2634
[30-Jan-2021 22:13:13 UTC] PHP Warning:  array_merge(): Expected parameter 2 to be an array, bool given in /var/app/current/wp-content/themes/my-theme/admin/product-search-fields.php on line 130
[30-Jan-2021 22:13:13 UTC] PHP Deprecated:  wpcf7_remove_shortcode is <strong>deprecated</strong> since Contact Form 7 version 4.6! Use wpcf7_remove_form_tag instead. in /var/app/current/wp-content/plugins/contact-form-7/includes/functions.php on line 351
[30-Jan-2021 22:13:13 UTC] PHP Deprecated:  wpcf7_remove_shortcode is <strong>deprecated</strong> since Contact Form 7 version 4.6! Use wpcf7_remove_form_tag instead. in /var/app/current/wp-content/plugins/contact-form-7/includes/functions.php on line 351
[30-Jan-2021 22:13:13 UTC] PHP Notice:  Undefined variable: post_id in /var/app/current/wp-content/themes/my-theme/admin/product-search-fields.php on line 22

我已经安装了 wp cli,并预制了:

wp  cron event run --due-now 

就是这样的结果:

PHP Notice:  Constant WP_DEBUG already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 97
Warning: array_merge(): Expected parameter 2 to be an array, bool given in /var/app/current/wp-content/themes/my-theme/admin/fields.php on line 2634
Warning: array_merge(): Expected parameter 2 to be an array, bool given in /var/app/current/wp-content/themes/my-theme/admin/product-search-fields.php on line 130
Deprecated: wpcf7_remove_shortcode is <strong>deprecated</strong> since Contact Form 7 version 4.6! Use wpcf7_remove_form_tag instead. in /var/app/current/wp-content/plugins/contact-form-7/includes/functions.php on line 351
Deprecated: wpcf7_remove_shortcode is <strong>deprecated</strong> since Contact Form 7 version 4.6! Use wpcf7_remove_form_tag instead. in /var/app/current/wp-content/plugins/contact-form-7/includes/functions.php on line 351
Notice: Undefined variable: post_id in /var/app/current/wp-content/themes/my-theme/admin/product-search-fields.php on line 22
Executed the cron event 'deliciousbrains_wp_offload_ses_queue_connection' in 0.038s.
Executed the cron event 'wp_privacy_delete_old_export_files' in 0.031s.
Executed the cron event 'w3_cdn_cron_queue_process' in 0.034s.
Success: Executed a total of 3 cron events.

看起来 cron 正在运行,但是当我查看 Offload SES Lite DIAGNOSTIC 时

INFO I see this: 
WP Cron: Disabled
Alternate WP Cron: Enabled
Last Run: 12:36:03 2021-01-07 UTC
Next Scheduled: 21:24:43 2021-01-30 UTC
Queued: 29
Failures: 878

看起来通过电子邮件执行的 ses cron 没有发送也没有失败,它们只是停留在队列中。

我跑了:

wp cron test

得到:

PHP Notice:  Constant WP_DEBUG already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 97
Warning: array_merge(): Expected parameter 2 to be an array, bool given in /var/app/current/wp-content/themes/my-theme/admin/fields.php on line 2634
Warning: array_merge(): Expected parameter 2 to be an array, bool given in /var/app/current/wp-content/themes/my-theme/admin/product-search-fields.php on line 130
Deprecated: wpcf7_remove_shortcode is <strong>deprecated</strong> since Contact Form 7 version 4.6! Use wpcf7_remove_form_tag instead. in /var/app/current/wp-content/plugins/contact-form-7/includes/functions.php on line 351
Deprecated: wpcf7_remove_shortcode is <strong>deprecated</strong> since Contact Form 7 version 4.6! Use wpcf7_remove_form_tag instead. in /var/app/current/wp-content/plugins/contact-form-7/includes/functions.php on line 351
Notice: Undefined variable: post_id in /var/app/current/wp-content/themes/my-theme/admin/product-search-fields.php on line 22
Warning: WP-Cron spawn succeeded but returned HTTP status code: 403 Forbidden

任何想法可能是错的? 此外,我只需要 cron 来处理电子邮件。有没有办法用 cli 运行 wp-ses?

php wordpress cron amazon-ses
3个回答
0
投票

我会建议一个一个地解决任何通知,并尝试构建解决方案。

例子:

注意:未定义变量:/var/app/current/wp-content/themes/my-theme/admin/product-search-fields.php 第22行的post_id 警告:WP-Cron spawn 成功但返回 HTTP 状态代码:403 Forbidden

文件 themes/my-theme/admin/product-search-fields.php 的第 22 行发生了什么?


0
投票

wp-cron.php
停止工作时,我在我的一个项目中遇到了类似的问题。我通过 Linux 服务器上的备用 cronjob 解决了这个问题。

*/5 * * * * cd /var/www/website_domain; php -q wp-cron.php >/dev/null 2>&1


0
投票

我解决了将 php 版本 8.2 降级到 7.4 的问题。也许缺少对 php +8 的插件支持?

© www.soinside.com 2019 - 2024. All rights reserved.