[ad_1]
Inside the wp-cron.php file, I’ve added error_logs to the following block on code:
$doing_cron_transient = get_transient( 'doing_cron' );
error_log('transient: ' . $doing_cron_transient);
// Use global $doing_wp_cron lock, otherwise use the GET lock. If no lock, try to grab a new lock.
if ( empty( $doing_wp_cron ) ) {
if ( empty( $_GET['doing_wp_cron'] ) ) {
// Called from external script/job. Try setting a lock.
if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) ) {
return;
}
error_log('changed transient');
$doing_wp_cron = sprintf( '%.22F', microtime( true ) );
$doing_cron_transient = $doing_wp_cron;
set_transient( 'doing_cron', $doing_wp_cron );
} else {
$doing_wp_cron = $_GET['doing_wp_cron'];
}
}Analyzing the logs I get:
“transient: 1668177825.6516680717468261718750
transient: 1668177892.6816198825836181640625
changed transient
transient: 1668178005.6597940921783447265625
changed transient
transient: 1668178125.6161699295043945312500
changed transient
transient: 1668178305.6940948963165283203125
transient: 1668178376.6249730587005615234375
changed transient
transient: 1668178485.7478859424591064453125
changed transient
transient: 1668178605.7118799686431884765625
changed transient
transient: 1668178725.7522399425506591796875
changed transient
transient: 1668178845.6465239524841308593750
changed transient
transient: 1668179032.0026690959930419921875”I don’t understand how get_transient( 'doing_cron' ) is changing value from 1668177825.6516680717468261718750 to 1668177892.6816198825836181640625, and 1668178305.6940948963165283203125 to 1668178376.6249730587005615234375. Shouldn’t the value remain the same?
As a result of this my cron job to call wp-cron.php every 2 minutes doesn’t work as pretended:*/2 * * * * su daemon -s /bin/sh -c "cd /opt/bitnami/wordpress; /opt/bitnami/php/bin/php -q wp-cron.php
