johnbillion / wp-crontrol

Take control of the cron events on your WordPress website
https://wp-crontrol.com
GNU General Public License v2.0
208 stars 36 forks source link

Making sure WordPress Cron runs #105

Closed szepeviktor closed 1 year ago

szepeviktor commented 1 year ago

I've found no way in core to look up when WordPress Cron ran the last time.

<?php

add_filter(
    'pre_set_transient_doing_cron',
    static function ($value) {
        update_option('cron_last_run', $value, 'no');
        return $value;
    },
    0,
    1
);

This MU plugin records the time of last run in an option called cron_last_run.

Then it can be compared to current time: wp option get cron_last_run

(I use Linux cron jobs to run WordPress Cron)

johnbillion commented 1 year ago

Thanks! Closing in favour of #19 which I'll get to... one day...