WordPress.org

Support

Support » Plugins and Hacks » cron wp_schedule_event

cron wp_schedule_event

  • I can’t get wordpress’ cronjob work:

    Here what I have done:

    <?php
    
    function hlex_install() {
    	wp_schedule_event(time(), 'hourly', 'hlex_timing_job');
    }
    
    function hlex_cronjob() {
        die('cronjob');
    }
    
    function hlex_deactivation() {
    	wp_clear_scheduled_hook('hlex_timing_job');
    }
    
    register_activation_hook(__FILE__, 'hlex_install');
    
    register_deactivation_hook(__FILE__, 'hlex_deactivation');
    
    add_action('hlex_timing_job', 'hlex_cronjob');
    ?>

    The wp_schedule_event works cause I can see in the table wp_options (option_name=’cron’ ) something like: i:1270343829;a:1:{s:15:”hlex_timing_job”;

    wp_clear_scheduled_hook works too because if I deactivate the plugin “hlex_timing_job” has gone from the “cron” row of the wp_options table.

    The problem is that hlex_cronjob() is never executed or at least I’ve never seen the word ‘cronjob’ printed.

    I hope someone can help me.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • I wasn’t sure if the cron function will be called directly or by CURL so I changed the hlex_cronjob() to see if it’s called:

    function hlex_cronjob() {
    	update_option('hlex_test', now());
    }

    Now i’m sure that is not called because I can see in wp_options that the row hlex_test is not updated.

    So i still can’t find a solutions :/

    javiarques

    @javiarques

    I recommend you to install “GD Press Tools” plugin where you can see if your event has been correctly scheduled.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘cron wp_schedule_event’ is closed to new replies.
Skip to toolbar