微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决Wordpress wp-cron.php 执行不起作用

我有一个站点 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 是 runnign,但是当我查看 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/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?

解决方法

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

示例:

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

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

,

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

wp-cron.php

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。