there are many post on stackoverflow with this topic but (i dont know why) nothing will work for me.
What i have
function isa_add_every_three_minutes( $schedules ) { $schedules['every_three_minutes'] = array( 'interval' => 180, 'display' => __( 'Every 3 Minutes', 'textdomain' ) ); return $schedules; } add_filter( 'cron_schedules', 'isa_add_every_three_minutes' ); function every_three_minutes_event_func() { // do something } wp_schedule_event( time(), 'every_three_minutes', 'every_three_minutes_event_func' );
Any ideas what i'm doing wrong?
Creating a single job that calls your site's wp-cron. php script every 15 minutes is all you should need. WP-Cron will take care of the rest. You will need to adjust your job if you create new schedules that need to run more frequently than every 15 minutes.
Run a Cron Job after every 10 minutes The slash operator helps in writing the easy syntax for running a Cron job after every 10 minutes. In this command, */10 will create a list of minutes after every 10 minutes.
“At every 5th minute.” Cron job every 5 minutes is a commonly used cron schedule. We created Cronitor because cron itself can't alert you if your jobs fail or never start.
You need to use add_action()
to hook your function to the scheduled event.
add_action( 'isa_add_every_three_minutes', 'every_three_minutes_event_func' );
Here is the full code.
// Add a new interval of 180 seconds // See http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules add_filter( 'cron_schedules', 'isa_add_every_three_minutes' ); function isa_add_every_three_minutes( $schedules ) { $schedules['every_three_minutes'] = array( 'interval' => 180, 'display' => __( 'Every 3 Minutes', 'textdomain' ) ); return $schedules; } // Schedule an action if it's not already scheduled if ( ! wp_next_scheduled( 'isa_add_every_three_minutes' ) ) { wp_schedule_event( time(), 'every_three_minutes', 'isa_add_every_three_minutes' ); } // Hook into that action that'll fire every three minutes add_action( 'isa_add_every_three_minutes', 'every_three_minutes_event_func' ); function every_three_minutes_event_func() { // do something } ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With