WordPress (WP-Cron)
WordPress uses its own cron system (WP-Cron) that runs on page visits. You can add WatchCron pings to any scheduled WordPress hook:
functions.php or custom plugin
// Schedule the event on activation if (!wp_next_scheduled('my_daily_cleanup')) { wp_schedule_event(time(), 'daily', 'my_daily_cleanup'); } // Hook the function add_action('my_daily_cleanup', function() { $pingUrl = 'https://watchcron.com/ping/your-uuid'; wp_remote_get("$pingUrl/start"); try { // Clean up expired transients, revisions, etc. global $wpdb; $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_%' AND option_value < UNIX_TIMESTAMP()" ); wp_remote_get($pingUrl); } catch (Exception $e) { wp_remote_get("$pingUrl/fail"); } });
WP-Cron only runs when someone visits your site. On low-traffic sites, tasks may be delayed. For reliable scheduling, disable WP-Cron (
define('DISABLE_WP_CRON', true); in wp-config.php) and trigger it with a real cron job: */5 * * * * wget -qO- https://yoursite.com/wp-cron.php