I’m trying to execute a WP cron job but it doesn’t seem to be executed (even XDebuger doesn’t seem to fire).

add_action('init', initing_cron);
add_action('my_test_cron', my_cron);

function initing_cron()
{
    if (!wp_next_scheduled('my_test_cron'))
    {
        wp_schedule_event(time(), '2min', 'my_test_cron');
    }
}

function my_cron()
{
    $var = '';
    file_put_contents(__DIR__ . DIRECTORY_SEPARATOR .'crontest.txt', 'hello world');
}

I’d really appreciate if anyone could let me know what I’m doing wrong. There are no cache plugins installed. It seems wp_next_scheduled is actually returning the correct value. It just doesn’t seem to fire my_cron() at all.

Read more here: WP Cron job Not Executing


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: