Cron jobs are the source of more “the server is slow at 3am” tickets on cPanel than almost anything else. A customer adds a “run this every minute” cron, the script takes 90 seconds to complete, and within a week there are 100 of them running concurrently. The right policy isn’t “no crons” — it’s bounded crons with enforced limits.
The trade-off
Customers need cron. WordPress cron via real cron (instead of WP’s pseudo-cron) is a meaningful performance improvement. Backup scripts, queue workers, mail jobs — all legitimate. The risk is the same as with any other resource: one tenant’s runaway cron becomes everyone’s problem.
How to decide — the policy dimensions
- Minimum frequency. Default cPanel allows every-minute cron. For shared hosting, raise this to every-5-minutes (or higher for low-tier plans). cPanel doesn’t enforce minimum interval natively; you enforce by educating customers and via LVE limits.
- Maximum running time. Use
timeoutin cron commands:timeout 60 /home/user/script.sh. Document this as standard practice. - Concurrent execution. Use
flockto prevent the same cron from running twice if the previous instance hasn’t finished:flock -n /tmp/cron.lock /home/user/script.sh. - Resource limits per cron. LVE applies to cron jobs via
lveuser_setif you want different limits than the user’s standard LVE. - Logging. Output should go to a tenant-visible log file with rotation, not to email-on-stdout (which floods Exim).
- Lower bound on actual frequency. Some “every minute” cron jobs only need to run hourly. Audit periodically.
What to do — operator policy
- Publish a cron policy in your plan documentation. “Crons may not run more than once every 5 minutes on Standard plans” is a defensible position.
- Default new accounts to crontab restricted via PAM or by stripping the
crontabbinary on lowest-tier plans. - Monitor cron CPU contribution per tenant.
lveinfo --period=1d --by-fault=cpufiltered to identify cron-driven faults. - Document the patterns customers should use:
timeoutto cap runtimeflockto prevent overlap- Log redirection to file, not email
- Random offset to prevent thundering herd (e.g.,
* * * * * sleep $((RANDOM % 30)); /home/user/script.sh)
- Reach out to tenants whose crons cause issues before they cause an outage. Most customers don’t realize their cron is the problem.
- Provide a sandbox cron environment for testing. Customers shouldn’t debug crons in production.
- For the WordPress-specific case, replace WP’s pseudo-cron with real cron via WHM > MultiPHP Manager, but enforce a reasonable frequency.
Stack Harbor sets and enforces cron policy as part of cPanel/WHM management.