Skip to content

liedekef/table-cron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Table Cron

Replaces WordPress's option-based cron storage with a dedicated database table for proper task tracking.

Why?

WordPress stores all scheduled cron events in a single serialized row in wp_options. This causes problems:

  • Concurrency issues — concurrent requests can overwrite each other's changes to the cron array.
  • No visibility — events are buried in a serialized blob, making debugging difficult.
  • Performance — the entire cron array is loaded and rewritten on every schedule/unschedule operation.
  • Unreliable deletion — garbage collection of expired transients and old posts depends on cron events that may be silently lost.

Table Cron tries to solve this by storing each event as its own row in a dedicated database table. See also https://core.trac.wordpress.org/ticket/57271

How it works

  • Intercepts all cron operations via the official pre_* filters (pre_schedule_event, pre_unschedule_event, etc.).
  • Stores individual events in a {prefix}_cron table instead of a serialized wp_options row.
  • Fully backwards-compatible with wp_schedule_event(), wp_schedule_single_event(), and all standard cron APIs.
  • On activation, migrates existing option-based events into the table.
  • On deactivation, migrates events back and drops the table.

Features

  • Admin page — View all scheduled cron tasks under Tools > Cron Tasks, with overdue indicators and the ability to delete individual events.
  • Core event protection — WordPress core cron hooks are locked and cannot be deleted from the admin UI.
  • Nice schedule names — The admin page shows human-readable schedule labels (e.g. "Once Hourly") instead of internal names.
  • Duplicate detection — Prevents scheduling the same single event twice within a 10-minute window.
  • last_run tracking — Records when each event was last picked up for execution.
  • Multisite compatible — Works on both single site and multisite installs.

Requirements

  • WordPress 6+
  • PHP 8+
  • MySQL 5.7+ or MariaDB 10.2+

Installation

  1. Upload the table-cron folder to /wp-content/plugins/.
  2. Activate the plugin through the Plugins menu.
  3. Done — existing cron events are automatically migrated.

Deactivation

When deactivated, all events are migrated back to the wp_options cron row and the table is dropped. No data is lost.

License

GPL-2.0-or-later

About

small WP plugin to replace cron option by a db table, solving concurrent issues

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages