Knowledgebase

WHMCS Custom Cron Settings Guide Print

  • 0

WHMCS Custom Cron Settings Guide

Setting up custom cron jobs in WHMCS is essential for automating various tasks like billing, invoice generation, domain synchronization, and more. This guide explains the purpose, configuration, and customization of cron settings in WHMCS, allowing you to optimize system performance and ensure seamless automation.


What is WHMCS System Cron?

The System Cron is a core feature in WHMCS that automates recurring tasks such as billing, notifications, and maintenance. Properly configuring it ensures smooth operation and consistent task execution.


Setting Up System Cron

  1. Locating the Cron Command
    To find the correct cron command:

    • Go to Configuration > System Settings > Automation Settings in your WHMCS admin panel.
    • Copy the cron command provided, which looks like this:
      */5 * * * * php -q /home/username/crons/cron.php
      
    • Replace /home/username/crons/cron.php with your actual cron.php path.
  2. Configuring the Cron Job
    Use your hosting control panel (like cPanel or Plesk) or the command line to add the cron job. For example:

    • For a 5-minute interval:
      */5 * * * * php -q /path/to/cron.php
      
  3. Adjusting Execution Time
    Set the time for daily automated tasks via Configuration > System Settings > Automation Settings > Time of Day. Ensure the cron runs during the set hour.


Common Cron Tasks

  1. System Cron

    • Runs core automation tasks like invoice generation, billing, and service management.
    • Recommended interval: Every 5 minutes. Minimum: Once per hour.
  2. POP Email Import Cron

    • For importing support emails via the POP3 protocol.
    • Example command:
      */5 * * * * php -q /path/to/pop.php
      
    • Note: Email piping is a better alternative for support ticket automation.

Customizing Cron Tasks

WHMCS allows customization of the cron command with arguments and options to control task execution. Here's how:

  1. Available Arguments

    • all: Run all due automation tasks (default).
    • do: Run only specified tasks. Example:
      */5 * * * * php -q /path/to/cron.php do --AutoSuspensions
      
    • skip: Skip specified tasks. Example:
      */5 * * * * php -q /path/to/cron.php skip --DomainRenewalNotices
      
    • list: List all available arguments.
    • help: Display help for arguments or tasks.
  2. Options for Advanced Customization

    • --force: Force execution of tasks regardless of schedule.
    • -v, -vv, -vvv: Set verbosity levels for output.
    • --email-report: Send a detailed email report after cron execution.
  3. Custom Task Scheduling
    To execute specific tasks at different times:

    • Main cron skips some tasks:
      */5 * * * * php -q /path/to/cron.php skip --TicketEscalations --AutoSuspensions
      
    • Separate cron for specific tasks:
      • Ticket escalations during business hours:
        0 9,10,11,12,13,14,15,16 * * 1-5 php -q /path/to/cron.php do --TicketEscalations
        
      • Automatic suspensions on weekday mornings:
        0 9 * * 1-5 php -q /path/to/cron.php do --AutoSuspensions
        

Security Best Practices

  1. Secure the Cron Directory
    Move the crons directory outside the public document root to prevent unauthorized access.

  2. Restrict Cron Access
    Use server-level authentication or IP restrictions for cron access.


HTTP Invocation

If your hosting environment doesn’t support direct cron jobs, use HTTP requests to invoke the cron:

  • Example GET request:
    GET http://www.example.com/admin/cron.php?command=skip&options=DomainRenewalNotices,TicketEscalations
    

Tasks Overview

Below are common WHMCS tasks and their frequencies:

Task Description Frequency
--AddLateFees Apply late fees to overdue invoices. Daily
--DomainRenewalNotices Send domain renewal notices. Daily
--CreateInvoices Generate new invoices. Daily
--TicketEscalations Process ticket escalation rules. As often as 3 mins
--AutoSuspensions Suspend overdue services. Daily
--DatabaseBackup Backup the database. Daily

For more detailed scheduling, see WHMCS’s official documentation.


Conclusion

Properly configuring WHMCS cron settings ensures efficient automation and smooth system operation. By understanding and customizing tasks to your needs, you can optimize your WHMCS installation while maintaining security and performance. For advanced scenarios, consult WHMCS Developer Documentation or your hosting provider for assistance.


Was this answer helpful?
Back