WP Manifestindependent plugin directory
manifest / performance / real-cron-bridge

Real Cron Bridge

Replace WordPress pseudo-cron with deterministic execution via system cron

by Anas Nagati · github.com/anas-nagati/real-cron-bridge · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/anas-nagati/real-cron-bridge/archive/refs/heads/main.zip

Real Cron Bridge for WordPress

Replace WordPress pseudo-cron with deterministic execution driven by real system cron while remaining fully compatible with WordPress core scheduling APIs.

Features

  • Deterministic execution - Events run on schedule, not on page load
  • Zero traffic dependency - Works without any visitors
  • Lock-based concurrency control - Prevents overlapping executions
  • Two execution methods - WP-CLI (recommended) and HTTP fallback
  • Secure authentication - Cryptographically secure tokens with constant-time comparison
  • Comprehensive diagnostics - Track execution history, errors, and health
  • No WordPress modifications - Fully compatible with existing scheduled events

Requirements

  • WordPress 6.0+
  • PHP 7.4+
  • System cron access (crontab)
  • WP-CLI (recommended but optional)

Installation

  1. Upload the plugin folder to /wp-content/plugins/
  2. Activate the plugin through the WordPress admin
  3. Add to wp-config.php: define('DISABLE_WP_CRON', true);
  4. Configure system cron (see Usage below)

Usage

Method 1: WP-CLI (Recommended)

Add to your system crontab:

*/5 * * * * cd /path/to/wordpress && wp real-cron run

This runs every 5 minutes. Adjust frequency as needed.

Method 2: HTTP Endpoint (Fallback)

  1. In WordPress admin, go to Tools → Real Cron Bridge
  2. Enable "HTTP Runner" and generate a secure token
  3. Add to your system crontab:
*/5 * * * * curl -s "https://example.com/?rcb_exec=1&token=YOUR_TOKEN" > /dev/null 2>&1

Important: The token is shown only once. Save it immediately.

Security

  • HTTP endpoint requires a 64-character cryptographic token
  • Tokens are hashed using bcrypt before storage
  • Constant-time comparison prevents timing attacks
  • No predictable URLs or nonce-only protection
  • Execution requires authentication

Configuration

Available settings in admin interface:

  • Lock TTL - Maximum lock duration (default: 60 seconds)
  • Overdue Threshold - Time before events are considered overdue (default: 300 seconds)
  • HTTP Runner - Enable/disable HTTP execution endpoint

Diagnostics

The admin page displays:

  • Last successful run timestamp
  • Last failure timestamp and error message
  • Total execution count
  • Average execution duration
  • Number of overdue events
  • Current lock status
  • Recent error log (last 10 errors)

How It Works

  1. System cron triggers execution (via WP-CLI or HTTP)
  2. Plugin checks for and acquires execution lock
  3. Sets DOING_CRON constant
  4. Calls WordPress core cron runner (spawn_cron())
  5. WordPress processes all due events normally
  6. Plugin releases lock and logs results

The plugin does not reimplement WordPress scheduling logic. It simply triggers the existing WordPress cron system on a reliable schedule.

Troubleshooting

"Cron execution is already in progress"

Another execution is running or a lock is stuck. Use "Force Unlock" in admin if needed.

"No events due"

No scheduled events are ready to run. This is normal.

Events still not running

  1. Verify DISABLE_WP_CRON is set to true in wp-config.php
  2. Check system cron is configured correctly: crontab -l
  3. Review error log in admin interface
  4. Ensure PHP has sufficient memory and execution time

HTTP endpoint returns 403

Token is invalid or missing. Regenerate token in admin.

File Structure

real-cron-bridge/
├── real-cron-bridge.php          # Main plugin file
├── includes/
│   ├── class-lock-manager.php     # Concurrency control
│   ├── class-cron-executor.php    # Core execution logic
│   ├── class-diagnostics.php      # Logging and monitoring
│   └── class-http-runner.php      # HTTP endpoint handler
├── admin/
│   └── class-admin-page.php       # Settings interface
└── README.md

Frequently Asked Questions

Q: Will this break my existing scheduled events?
A: No. All WordPress scheduled events continue to work normally. The plugin only changes how they're triggered.

Q: Do I need to modify my theme or other plugins?
A: No. The plugin works transparently with all existing code using wp_schedule_event() and related functions.

Q: What happens if I deactivate the plugin?
A: WordPress falls back to traffic-based cron execution (if DISABLE_WP_CRON is removed from wp-config.php).

Q: Can I use both WP-CLI and HTTP methods?
A: Yes, but only one should be active in cron to avoid redundant executions.

License

GPL v2 or later

Support

For issues and questions, please use the WordPress.org support forums or GitHub issues.