Skip to content

Cron job stampedes on cPanel — when everyone runs at :00

When many cPanel accounts schedule their crons for the top of the hour, the host gets a thundering herd at minute zero. Here is how to detect and spread the load.

The cPanel cron UI shows minutes 0 through 59 as a dropdown, and humans pick “0” because it is the natural default. On a host with 100 cPanel accounts, that means at every top of the hour, dozens of WordPress sites run wp-cron, dozens of backup scripts fire, and dozens of mail-queue runners launch. CPU spikes, IO saturates, and any customer hitting the site at xx:00:05 sees a slow response. The diagnosis is obvious once you look at the cron landscape; the fix is mechanical.

What’s happening

Cron itself is fine — it dispatches all jobs scheduled for the same minute essentially simultaneously. The problem is the convergence of many independent decisions on the same minute. WordPress’s wp-cron is often run from a real cron entry at 0 * * * * (once per hour). Backup tools default to nightly at 0 2 * * *. Cleanup scripts pick 0 4 * * *. Each individual job is reasonable; the aggregate is a thundering herd.

On a single host with one user, this does not matter. On a shared cPanel host with many accounts, the minute :00 spike can drive the load 3-5x its baseline. The customers running cron at :00 are fine — they got their slice. The customers serving HTTP traffic during the spike see degraded response.

How to verify

Inventory all crons on the host by minute:

for u in $(cut -d: -f1 /etc/userdomains); do
  if [ -f /var/spool/cron/$u ]; then
    awk '!/^#/ && NF>=6 {print $1}' /var/spool/cron/$u
  fi
done | sort | uniq -c | sort -rn | head -10

This prints the count of cron entries grouped by minute. If 0 is dramatically higher than other values, you have a stampede.

Look at the actual host load over a minute boundary:

sar -u -s 23:59:00 -e 00:01:00 | head -20

A clear CPU spike at exactly :00 indicates the stampede.

For per-account cron review:

crontab -u <user> -l
ls /var/spool/cron/ | head

The fix

  1. Add jitter to wp-cron via WP-CLI or a stagger script. Instead of 0 * * * *:

    0,15,30,45 * * * * sleep $((RANDOM % 600)) && cd /home/<user>/public_html && wp cron event run --due-now

    The sleep $((RANDOM % 600)) adds 0-10 minutes of random delay. Each account’s wp-cron now fires somewhere in a 10-minute window instead of all at :00.

  2. Spread system crons across the hour. Daily backups: instead of 0 2 * * *, use RANDOM=somehash per host or a custom minute. For a fleet, generate a stagger schedule.

  3. For new accounts, default to a non-:00 minute. Customize the cPanel default cron template or document the convention.

  4. Use systemd timers with RandomizedDelaySec for system-level scheduled tasks. Built-in jitter without custom code.

  5. For wp-cron specifically, disable real cron and use external triggering. WP-CLI from a host-wide scheduler that knows about the stagger:

    # In wp-config.php
    define('DISABLE_WP_CRON', true);

    Then a single host cron loops through all accounts with a stagger:

    */5 * * * * for u in $(cut -d: -f1 /etc/userdomains); do (sleep $((RANDOM % 240)) && sudo -u $u wp --path=/home/$u/public_html cron event run --due-now) & done
  6. Audit monthly. New accounts often default back to :00 crons. A simple script that detects high :00 density flags the issue.

After spreading, the sar view should be flat across the hour instead of spiked at :00. Customer response times during the previous spike window should normalize. Stack Harbor manages cron schedules across fleets as part of cPanel/WHM management.