1register_activation_hook( __FILE__, 'my_activation' );
2add_action( 'my_hourly_event', 'do_this_hourly' );
3
4function my_activation() {
5 wp_schedule_event( time(), 'hourly', 'my_hourly_event' );
6}
7
8function do_this_hourly() {
9 // do something every hour
10}
11
12register_deactivation_hook( __FILE__, 'my_deactivation' );
13
14function my_deactivation() {
15 wp_clear_scheduled_hook( 'my_hourly_event' );
16}