[wp-hackers] Cron Tasks doesn't update_options

Otto otto at ottodestruct.com
Mon Mar 21 22:16:22 UTC 2011


You're using wp_schedule_event incorrectly.

wp_schedule_event(time(), 'minute', 'cron_plugin_action');

The third parameter is an *action*, not a callback function name.
Later you have this code:

/* Cron function */
function cron_plugin_action(){
    update_option( 'cron_plugin_time', time() );
}

In order for that to work, you would also need:
add_action('cron_plugin_action', 'cron_plugin_action');

In order to hook the action name to the function name.

Basically, your function is never being run.

-Otto



On Mon, Mar 21, 2011 at 5:12 PM, Craig Russell
<craig at craig-russell.co.uk> wrote:
> Hello,
>
> It seems like cronned tasks can't update options in my setup.
>
> I've written a basic plugin to illustrate the effect here
> https://github.com/craig552uk/cron-plugin/blob/master/main.php
> The plugin simply updates a stored option to the current time each
> time it is run.
> The settings page of the plugin shows the scheduled time for the task
> to run (which updates) and the stored time (which does not update).
>
> Am I overlooking something in my configuration?
> Are there any special server configs for cron to run correctly?
> Or is this a more general problem with cron? (probably not this)
>
> Any help greatly appreciated.
>
> -Craig
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list