wp-cli/cron-command

wp cron event run --due-now is not updating timestamps, causing jobs to run multiple times and appear past due

jpSimkins opened this issue · 2 comments

I am using wp cron event run --due-now to run cron jobs on a real cron that runs every 5 mins. I have DISABLE_WP_CRON set to true.

When I run wp cron event run --due-now the cron jobs run as expected and they are completing with no errors.

The issue I am having, is that this is not updating the timestamp in WordPress. The cron jobs, that just ran, are showing past due in crontrol. If I run wp cron event run --due-now again, the same cron jobs will run.

If I go to the URL endpoint to trigger cron, then it works as expected, properly updating the timestamps. This issue only happens with wp cli.

This also causes issues with wp_schedule_single_event as after it runs, it is still left in the cron queue even though it completed. Again, if I run it from the domain endpoint it works as expected. This is a bigger issue as these single event crons are normally tools used to repair data in the system and are pretty heavy to process. Having this run every 5 mins has serious performance impact.

I do not have any errors being reported and when running in debug, I don't see any issues. I also checked the site health to make sure there weren't any issues and there are none listed there.

I am using memcached and I even disabled it to check if this was a caching issue and that is not the case. I have completely removed memcached from the system and it still does this.


$  wp cli info
OS:     Linux 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64
Shell:  
PHP binary:     /usr/local/bin/php
PHP version:    7.4.33
php.ini used:   /usr/local/etc/php/php.ini
MySQL binary:   
MySQL version:  
SQL modes:      
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /var/www/html
WP-CLI packages dir:    
WP-CLI cache dir:       /var/www/.wp-cli/cache
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 2.7.1

suhosin is not installed.

no packages are installed. This is a vanilla wp cli.

I am reopening this to see if this is something that can be addressed here.

While my assumption was this is an issue due to W3TC object-cache.php, I do want to make note that this only happens when using wp cron. If I go to the cron endpoint in the URL, then the cron jobs process and update the timestamps as expected.

I don't know how to debug with wp-cli and I am having to resort to using the URL to debug the cron issue I am experiencing. Since this only happens on the wp cli, there is no way I can properly debug this.

Confirmed this is a caching not related to wp-cli. wp cli is updating the timestamps properly