Shahid Malla

WHMCS Cron Jobs: Setup, Troubleshooting, and Optimization

Shahid Malla Shahid MallaJanuary 3, 202610 min read
WHMCS Cron Jobs: Setup, Troubleshooting, and Optimization

The WHMCS cron is the heart of automation. If it stops working, invoices don't generate, reminders don't send, and services don't provision.

What the Cron Does

  • Generates invoices for upcoming renewals
  • Sends payment reminders and overdue notices
  • Suspends and terminates overdue services
  • Processes domain renewals
  • Runs automated tasks and scheduled reports
  • Executes custom daily/weekly cron hooks

Cron Setup

Recommended Configuration

*/5 * * * * php -q /home/user/whmcs/crons/cron.php

Run every 5 minutes for timely automation.

System Cron vs Pop Cron

  • System Cron: Recommended. Runs via command line, more reliable.
  • Pop Cron: URL-based, triggered by clients visiting. Not reliable for busy sites.

Common Issues

Cron Not Running

  • Check crontab syntax with crontab -l
  • Verify PHP path is correct
  • Check file permissions on cron.php
  • Look for PHP errors in logs

Cron Running Slowly

  • Large activity log - clean up old entries
  • Many pending domain syncs - disable unnecessary syncs
  • Database optimization needed
  • Too many modules checking for updates

Monitoring

Check Utilities → System → Automation Status regularly. Set up external monitoring to alert if cron stops.

Optimization Tips

  • Disable unused automation tasks
  • Limit activity log retention
  • Stagger heavy tasks to off-peak hours
  • Use Redis/Memcached for caching

Cron Hooks

Add custom logic with cron hooks:

add_hook('DailyCronJob', 1, function($vars) {
    // Your daily automation
});

add_hook('AfterCronJob', 1, function($vars) {
    // Runs after every cron execution
});
Share this article:
Shahid Malla

About Shahid Malla

Expert

Full Stack Developer with 10+ years of experience in WHMCS development, WordPress, and server management. Trusted by 600+ clients worldwide for hosting automation and custom solutions.