Cron Jobs & Scheduled Tasks
The platform relies heavily on server-level cron jobs (not WordPress wp-cron) to perform automated maintenance, monitoring, and synchronization tasks. All cron scripts are located in Z:\Herd\manage\cron/.
Cron Architecture
Execution Method
All scripts are executed via server crontab as direct PHP processes:
# Example crontab entry
*/5 * * * * /usr/bin/php /path/to/manage/cron/site-updates.php >> /var/log/cron.log 2>&1
Each script bootstraps WordPress at the top:
<?php
// Bootstrap WordPress
require_once dirname(__DIR__) . '/wp-load.php';
// Script logic...
Why Server Cron (Not WP-Cron)
- Reliability: Server cron runs on schedule regardless of site traffic
- Long-running tasks: Some scripts take 10+ minutes (Harvest sync)
- Rate limiting: Scripts need precise timing for API delays
- No duplicate execution: Server cron prevents overlapping runs
Site Update Scripts
site-updates.php
Schedule: Every 5 minutes
Purpose: Processes the site update queue, syncing site data in batches.
Behavior:
- Reads next 15 sites from
suma_cronqueue - For each site, runs
Site_Updateclass sync (MainWP data, SSL check, plugins, themes) - Fires
suma_site_updatedhook (triggers Pinecone auto-sync) - Removes processed entries from queue
- Exits when queue is empty or batch limit reached
Key Details:
- Processes 15 sites per run to avoid timeouts
- Full cycle of all sites takes approximately 4–6 hours
- Sites are re-queued after full cycle completes
daily-site-check.php
Schedule: Daily (midnight)
Purpose: Comprehensive health check on all active sites.
Checks Performed:
- SSL certificate expiration
- Google indexing status
- WordPress version currency
- Plugin update availability
- Debug mode status
- WP-Cron functionality
- Missing H1 tags
- Contact page accessibility
update-servers.php
Schedule: Daily
Purpose: Syncs WP Engine server data via their REST API.
Behavior:
- Calls WP Engine API v0 for account installs
- Updates
suma_wpenginetable with PHP version, environment, domains - Updates
suma_server_domain_mappingtable
Monitoring Scripts
uptime-robot.php
Schedule: Every 15 minutes
Purpose: Syncs UptimeRobot monitoring data for all managed sites.
Behavior:
- Queries UptimeRobot API for all monitors
- Updates
suma_sites.uptimefield with current status - Logs any newly-detected downtime events
jetpack-protect.php
Schedule: Daily
Purpose: Fetches vulnerability data from Jetpack Protect API.
Behavior:
- Queries Jetpack vulnerability feed for all WordPress sites
- Updates
suma_vulnerabilitiesmaster table - Updates
suma_vulnerabilities_sitelinking table - Flags any new critical vulnerabilities
Reporting Scripts
daily-git-reports.php
Schedule: Daily (morning)
Purpose: Generates developer commit activity reports from Bitbucket.
Behavior:
- Queries Bitbucket API for recent commits across all repositories
- Updates
suma_git_statustable with developer activity - Generates summary for management review
daily-disconnected-report.php
Schedule: Daily
Purpose: Reports on MainWP child sites that have lost connection.
Behavior:
- Checks MainWP for sites with disconnected status
- Sends email report listing disconnected sites
- Triggers reconnection attempts for known-fixable cases
added-deleted-plugins-report.php
Schedule: Daily
Purpose: Reports on plugin changes across managed sites.
Behavior:
- Compares current plugin lists with previous day's snapshot
- Identifies newly added and removed plugins
- Sends email report to management
paid-inactive-plugins-report.php
Schedule: Weekly
Purpose: Identifies paid plugins that are installed but deactivated.
Behavior:
- Cross-references
suma_cost(paid plugins) with site plugin data - Identifies inactive paid plugins that are costing money
- Generates report for cost optimization review
unlicensed-plugin.php
Schedule: Weekly
Purpose: Finds plugins that lack proper licensing.
Behavior:
- Scans all sites for plugins without license keys in
suma_cost - Reports premium plugins potentially running unlicensed
- Helps ensure compliance with plugin vendor terms
Harvest & Time Tracking Scripts
check-for-new-sheets-projects.php
Schedule: Daily
Purpose: Checks Google Sheets for new project entries and creates matching Harvest projects.
Behavior:
- Reads project management Google Sheet
- Identifies entries without corresponding Harvest projects
- Creates new Harvest projects via API
- Updates sheet with Harvest project links
google-sheet-feature-update.php
Schedule: Daily
Purpose: Syncs feature/task data between Google Sheets and the management platform.
Screenshot & Visual Scripts
generate_screenshots.php
Schedule: Weekly
Purpose: Orchestrates screenshot generation for all managed sites.
schedule-screenshots.php
Schedule: Triggered by generate_screenshots
Purpose: Queues screenshot tasks into the processing pipeline.
take-screenshots.php
Schedule: Processes queue continuously
Purpose: Actually captures screenshots using Chrome PHP (headless Chromium).
Dependencies: chrome-php/chrome library for headless browser rendering.
sites-add-to-queue.php
Schedule: Called by site-updates cycle
Purpose: Rebuilds the suma_cron queue when empty.
Behavior:
- Checks if
suma_crontable is empty - Inserts all active (non-archived) sites into queue
- Randomizes order to distribute load
Maintenance Scripts
reconnect-main-wp.php
Schedule: Every 30 minutes
Purpose: Attempts to reconnect disconnected MainWP child sites.
Behavior:
- Identifies disconnected sites from MainWP
- Attempts reconnection via MainWP API
- Logs results for the disconnected report
update_cloudflare.php
Schedule: Daily
Purpose: Syncs Cloudflare zone data for managed sites.
Behavior:
- Queries Cloudflare API for all zones in account
- Updates
suma_sites.cf_zone_idfor matching domains - Verifies DNS/proxy configuration
Recommended Crontab
# Site updates (every 5 minutes)
*/5 * * * * /usr/bin/php /path/to/manage/cron/site-updates.php
# MainWP reconnection (every 30 minutes)
*/30 * * * * /usr/bin/php /path/to/manage/cron/reconnect-main-wp.php
# Uptime monitoring (every 15 minutes)
*/15 * * * * /usr/bin/php /path/to/manage/cron/uptime-robot.php
# Daily checks (midnight)
0 0 * * * /usr/bin/php /path/to/manage/cron/daily-site-check.php
# Daily reports (6 AM)
0 6 * * * /usr/bin/php /path/to/manage/cron/daily-git-reports.php
0 6 * * * /usr/bin/php /path/to/manage/cron/daily-disconnected-report.php
0 6 * * * /usr/bin/php /path/to/manage/cron/added-deleted-plugins-report.php
# Daily data sync
0 2 * * * /usr/bin/php /path/to/manage/cron/update-servers.php
0 3 * * * /usr/bin/php /path/to/manage/cron/check-for-new-sheets-projects.php
0 4 * * * /usr/bin/php /path/to/manage/cron/update_cloudflare.php
0 5 * * * /usr/bin/php /path/to/manage/cron/jetpack-protect.php
# Weekly reports (Monday 7 AM)
0 7 * * 1 /usr/bin/php /path/to/manage/cron/paid-inactive-plugins-report.php
0 7 * * 1 /usr/bin/php /path/to/manage/cron/unlicensed-plugin.php
# Weekly screenshots (Sunday 2 AM)
0 2 * * 0 /usr/bin/php /path/to/manage/cron/generate_screenshots.php
Troubleshooting
Script Fails Silently
- Check
wp-content/debug.logfor PHP errors - Verify WordPress can bootstrap:
php -r "require 'wp-load.php'; echo 'OK';" - Ensure database connectivity from cron environment
Site Updates Stuck
- Check
suma_crontable for stale entries - Verify MainWP child sites are connected
- Clear queue:
TRUNCATE TABLE suma_cron; - Re-queue: Run
sites-add-to-queue.phpmanually
Harvest Sync Timeout
- The sync takes 10+ minutes due to 10-second API delays
- Ensure PHP
max_execution_timeis set to 0 (unlimited) for CLI - Check Harvest API credentials in plugin settings
Screenshot Failures
- Verify Chrome/Chromium is installed on server
- Check
chrome-php/chromecan launch headless browser - Ensure sufficient memory for rendering (512MB+ recommended)