define( 'DISABLE_WP_CRON', true );That line is how you disable WP-Cron, and it’s the one change most WordPress stores need. WP-Cron doesn’t run on a clock. It checks for due tasks on every page load. That’s fine on a busy blog and quietly wrong on a quiet store, where a job set for 3am runs whenever the first visitor arrives, if one does.
I came to this sideways, through Ibrahim Salami’s piece on Towards Data Science about pushing a small ETL pipeline toward production. His pipeline broke three ways: it duplicated every row on each run, its database vanished with the notebook session, and someone still had to open the notebook and press run each morning. WordPress sites hit the same three walls in a different order, and the third one fails without an error.
The three walls in WordPress order
- No memory. There’s no unique constraint on wp_posts, or on the custom table you build yourself, so any importer that inserts on every run duplicates data the same way his 22 rows became 44. Product feed plugins do this. The error log stays clean the whole time.
- State that doesn’t survive. WordPress hands you this one for free, because MySQL is the persistence layer and the WP-Cron queue lives in the options table. It still bites where state sits in the object cache with no persistent backend, or where files land in a tmp directory the host clears on deploy.
- Somebody has to press run. In WordPress nobody presses run, traffic does. Scheduled posts, subscription renewals, queued emails and update checks all wait for a page load, and WooCommerce’s Action Scheduler leans on WP-Cron by default, so it inherits the same dependency on traffic.
The first two walls you fix in code and hosting choices. The third is the one people assume is handled, because WP-Cron has cron in the name and behaves nothing like crontab.
Make the job idempotent first
His idempotency fix was delete-then-insert, keyed on the repo URL. The same pattern works for a WordPress sync:
function bbioon_sync_repos( array $repos ) {
global $wpdb;
$table = $wpdb->prefix . 'github_repos';
foreach ( $repos as $repo ) {
// Delete the old row first, so reruns replace instead of append.
$wpdb->delete( $table, array( 'url' => $repo['url'] ), array( '%s' ) );
$wpdb->insert( $table, bbioon_repo_row( $repo ) );
}
}Run that once or ten times, the table looks the same. If the job goes through Action Scheduler, and on a WooCommerce store most background work does, the scheduler has its own guard: as_schedule_recurring_action() and friends accept a $unique argument, so a matching pending action isn’t created twice. One thing to check before you update: from Action Scheduler 4.0.0 on, the uniqueness check includes the action args, and code that leaned on the old hook-and-group-only match will create more actions than before, per the 4.0.0 release notes.
Disable WP-Cron, use the server’s clock
This is a two-step change. Put the constant in wp-config.php, above the “That’s all, stop editing” line, because anything defined after wp-settings.php loads is too late. Then give the server the job:
*/5 * * * * cd /var/www/example && wp cron event run --due-now >/dev/null 2>&1There’s a trade-off, and the plugin handbook states it: system cron doesn’t retry a missed slot, while WP-Cron queues everything and runs it on the next load. I still move stores over, because renewals and stock syncs deserve to run at a known minute, and because a page-load scheduler fails in a way nobody sees. I wrote out the full migration steps in an earlier post about replacing WP-Cron with a real server cron job.
Run wp cron event list on a store you manage and read the next_run_relative column. Anything overdue is a job waiting for traffic that never came. On WooCommerce, cross-check under Status, Scheduled Actions, where failed actions sit until someone looks. If that screen turns up jobs failing quietly, moving to system cron and rewriting a duplicate-prone import is the kind of cleanup I take on, so get in touch.