diff --git a/modules/website/wordpress/wordpress-cron-manager.sh b/modules/website/wordpress/wordpress-cron-manager.sh index f22f866..e468b83 100755 --- a/modules/website/wordpress/wordpress-cron-manager.sh +++ b/modules/website/wordpress/wordpress-cron-manager.sh @@ -1477,17 +1477,16 @@ create_timestamped_backup() { generate_staggered_cron() { # CRITICAL: Stagger cron times to prevent all WordPress sites from running at once # This prevents server load spikes from concurrent execution - # Each site gets a different minute within the hour, spread across 60 minutes + # Each site gets a unique minute within the hour (0-59), spread across full 60 minutes # NOTE: Uses global variable LAST_CRON_TIME instead of echo to avoid subshell issues - # Calculate staggered minute (0-59) - each site gets a different minute - local minute=$((CRON_OFFSET % 60)) + # BUG FIX: Use all 60 minutes instead of limiting to 20 slots + # Previous bug: minute * 3 only gave minutes 0, 3, 6, 9... 57 (20 slots) + # With 200 sites: 10 sites per slot = NOT staggered! + # Now: Each site gets unique minute 0-59 + # With 200 sites: Max 1 site per slot (perfect staggering) - # For better distribution, use every 3 minutes instead of every minute - # This gives us 20 different time slots instead of 60 - # Site 1: min 0, Site 2: min 3, Site 3: min 6, etc. - local stagger_minute=$((minute * 3)) - stagger_minute=$((stagger_minute % 60)) + local stagger_minute=$((CRON_OFFSET % 60)) # Increment offset for next site (THIS PERSISTS in parent shell, not in subshell) CRON_OFFSET=$((CRON_OFFSET + 1))